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" // } // ] // } // }
Sunday, August 18, 2019
Convert XML to JSON in C#
Subscribe to:
Post Comments (Atom)
How to register multiple implementations of the same interface in Asp.Net Core?
Problem: I have services that are derived from the same interface. public interface IService { } public class ServiceA : IService { ...
-
Microservice architecture, or simply microservices , is a distinctive method of developing software systems that tries to focus on buildi...
-
Introduction In this guide, we will tell you how to create a WhatsApp bot with C# by using our API WhatsApp gateway. The bot will receive co...
No comments:
Post a Comment