XML to Json

//// Install nuget package for Newtonsoft json
//// https://www.nuget.org/packages/Newtonsoft.Json/
//// Install-Package Newtonsoft.Json

 public static string ToJSON(this string xml)
        {
            // To convert an XML node contained in string xml into a JSON string
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);
            return JsonConvert.SerializeXmlNode(doc);
        }
Example:
String xmlString = "C:my.xml";
var jsonResult = xmlString.ToJSON();

Description

XML to Json

Details

Double click on the code to select all.

 

;