SerializeXmlNode


The JsonConvert has two helper methods for converting between JSON and XML. The first is SerializeXmlNode. This method takes an XmlNode and serializes it to JSON text.
HTML / XML
string xml = @"<?xml version=""1.0"" standalone=""no""?>
Code
<root>
Code
  <person id=""1"">
Code
  <name>Alan</name>
Code
  <url>http://www.google.com</url>
Code
  </person>
Code
  <person id=""2"">
Code
  <name>Louis</name>
Code
  <url>http://www.yahoo.com</url>
Code
  </person>
Code
</root>";
Code
Code
XmlDocument doc = new XmlDocument();
Code
doc.LoadXml(xml);
//for deserialize it in to json
string jsonText = JsonConvert.SerializeXmlNode(doc);