Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

from string

string xml = @"<?xml version='1.0' standalone='no'?>
/*<root>
  <person id='1'>
  <name>Alan</name>
  <url>http://www.google.com</url>
  </person>
  <person id='2'>
  <name>Louis</name>
  <url>http://www.yahoo.com</url>
  </person>
</root>
";
*/
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);

string json = JsonConvert.SerializeXmlNode(doc);

Console.WriteLine(json);
// {
//   "?xml": {
//     "@version": "1.0",
//     "@standalone": "no"
//   },
//   "root": {
//     "person": [
//       {
//         "@id": "1",
//         "name": "Alan",
//         "url": "http://www.google.com"
//       },
//       {
//         "@id": "2",
//         "name": "Louis",
//         "url": "http://www.yahoo.com"
//       }
//     ]
//   }
// }
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to destroy parent gameobject unity 
Csharp :: uri file path c# 
Csharp :: LINQ query on a DataTable C# 
Csharp :: stringbuilder to string c# 
Csharp :: how to concatenate two arrays in c# 
Csharp :: pyautopgui erros 
Csharp :: C# short getter setter 
Csharp :: default parameter c# 
Csharp :: jenga db connection 
Csharp :: multidimensional arrays c# 
Csharp :: To CharArray 
Csharp :: assembly project name c# .net 
Csharp :: wasd code for unity 
Csharp :: get the number of cpu c# 
Csharp :: c# tostring decimal 2 places 
Csharp :: asp.net format datetime 
Csharp :: how read excel data in c# 
Csharp :: prevent system shutdown c# 
Csharp :: C# trim trailing zero 
Csharp :: c# wpf row definition height * in code 
Csharp :: enable cors asp.net mvc 
Csharp :: unity master volume changer 
Csharp :: how to add data in list in c# 
Csharp :: c# get random index from list 
Csharp :: c# list foreach lambda multiple actions 
Csharp :: vb.net datagridview set row index 
Csharp :: c# static 
Csharp :: C# How to make a field read-only outside of class 
Csharp :: asp.net get most recent file in directory 
Csharp :: how to make 3d field of view in unity 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =