title: Load XML in MVC Controller
body: <p>I am trying to load up an XML document in MVC in the "HomeController"</p>
  
  <p>I want this document to load up in everything under the /Home/ directory so have my class:</p>
  
  <pre><code>public HomeController()
          {  }
  </code></pre>
  
  <p>And inside this I have the code that I want to connect to the XML with:</p>
  
  <pre><code>//Now set up the config xml read
          XmlDocument xmldoc = new XmlDocument();
          xmldoc.Load(HttpContext.Server.MapPath("~/Content/settings.xml"));
          XmlNodeList settings = xmldoc.SelectNodes("/settings");
          XmlNodeList defaults = xmldoc.GetElementsByTagName("default");
          foreach (XmlNode node in defaults)
          {
              string def_WebPageName = node["WebPageName "].InnerText;
          }
  </code></pre>
  
  <p>Structure of the XML:</p>
  
  <pre><code>&lt;settings&gt;
  &lt;defaults&gt;
    &lt;WebPageName&gt;blah&lt;/WebPageName&gt;
  &lt;/defaults&gt;
  </code></pre>
  
  <p>I cannot seem to locate theXML file, keep getting a "Object set to null reference" error</p>