dhanu shree

dhanu shree

  • NA
  • 72
  • 7.2k

While converting XML to JSON using c#

Mar 14 2018 2:23 PM
While converting XML to JSON using c#, By providing the data within the class,I’m getting the output.I need to fetch data from file present in folder .Could anyone please help me on this.
 
using Newtonsoft.Json;
using System;
using System.Windows.Forms;
using System.Xml;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(" \r\n Preethi\r\n 45679\r\n Electronics and communication\r\n \r\n #1, 6th cross \r\n Victoria Layout \r\n Bangalore\r\n India\r\n \r\n \r\n");
string jsonText = JsonConvert.SerializeXmlNode(doc);
//Console.WriteLine(jsonText);
MessageBox.Show(jsonText);
}
}
}

Answers (3)