⌘BABAKOV.NET Let's code!
100% [light] [ru]

Example of Deserializing XML to dynamic (Deserialize XML C#)

Example:

using System;
using Newtonsoft.Json;
using System.Xml.Linq;

namespace ConsoleAppTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string xml = @"<response><user>Roman</user><status>Active</status></response>";
            XDocument doc = XDocument.Parse(xml);
            string  jsn = JsonConvert.SerializeXNode(doc);
            dynamic response = JsonConvert.DeserializeObject(jsn);
            Console.WriteLine(response.response.status);
            Console.WriteLine(response.response.user);
            Console.ReadKey();
        }
    }
}

Comments (0)

No comments yet.

Leave a comment
Comment
Images (up to 5 MB)
Your comment will appear after moderation.