Пример #1
0
        static void Main(string[] args)
        {
            var xml = new XmlFormatter();

            Console.WriteLine("Data provided by Store.");
            Console.WriteLine(xml.ReadXml());
            Console.WriteLine(Environment.NewLine + ":*:*:---------------------------:*:*:" + Environment.NewLine);
            var wrapper = new WrapperData.XmlToJsonWrapper(xml);

            Console.WriteLine("Data converted to be stored on DB.");
            Console.WriteLine(wrapper.ConvertXmlToJson());
            Console.ReadLine();
        }
Пример #2
0
        public string ConvertXmlToJson()
        {
            var products = xmlFormatter.ReadXml()
                           .Element("Products")
                           .Elements("Product")
                           .Select(node => new Product
            {
                Name  = node.Attribute("Description").Value,
                Price = double.Parse(node.Attribute("Price").Value)
            });

            return(new JsonFormatter(products).ReadJson());
        }