I am trying to parse an xml file But facing error as output.dat file could not be found. Firstly I read all xml code in a string and then load it into xmlDocument object but face exception that output.dat not found here is my code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.XPath;
using System.IO;
namespace XML
{
class Program
{
static void Main(string[] args)
{
try
{
StreamReader sr = new StreamReader("output.xml");
String xml = "";
String line = sr.ReadLine();
while (line != null)
{
xml += line;
line = sr.ReadLine();
}
sr.Close();
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(xml);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
Kindly tell me where is error
Loadmethod to read to file directly? What is the exact exception message? Typically it will indicate what is wrong with the file.