title: How Read Xml File from Project Directory in C#?
body: <p>I need to know about to read xml file from project directory as shown below code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using crudpartialviewsjqureyajax.Models;
  using System.Data;
  using System.Xml;
  
  namespace crudpartialviewsjqureyajax.Controllers
  {
  
      public class snehprajapatController : Controller
      {
  
          public void getinstructors()
          {
              try
              {
                  List&lt;string&gt; name = null;
                  XmlDocument xml = new XmlDocument();
                  xml.LoadXml(@"~\App_Data\Trainings.xml");//Here given xml path location
                  XmlNodeList xnList = xml.SelectNodes("/Trainings/Training");
                  foreach (XmlNode xn in xnList)
                  {
                      new List&lt;string&gt;{
                  xn["name"].InnerText
                  };
  
                  }
  
                  //return name;
              }
              catch(Exception ex)
              {
                  Response.Write(ex.Message);
              }
  
          }
      }
  }
  </code></pre>
  
  <p>Here getting error is :</p>
  
  <pre><code>An unhandled exception of type 'System.Xml.XmlException' occurred in System.Xml.dll
  
  Additional information: Data at the root level is invalid. Line 1, position 1.
  </code></pre>
  
  <p>Please see the above code and suggest me what to for this?</p>
  
  <p>Thanks in Advance.</p>