JSON to XML

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

public static string ToXML(this string json)
{
      // To convert JSON text contained in string json into an XML node
      XmlDocument doc = JsonConvert.DeserializeXmlNode(json);
      return doc.ToString();
}
Example:
{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}}

Description

json to xml

Details

Double click on the code to select all.

 

;