How to Display an XML file to Console in Asp.Net

Description:-


In this article we will Create How to Open Xml File in Console Application. We can use XmlDocument to read an XML document. The Load method is used to load an XML into an XmlDocument. Once a document is loaded, we can use the Save method to display its content to the console. The key is, passing Console.Out as a parameter.

Code:-

static void Main(string[] args)
{
  XmlDocument xmlDoc = new XmlDocument();
  string filename = @"C:\Users\UmesH\Desktop\Customers.xml";
  xmlDoc.Load(filename);
  xmlDoc.Save(Console.Out);
  Console.ReadLine();
}

You must import the using System.Xml namespace in your code. 


Related Posts

Previous
Next Post »

Thanks for comments.....