title: How to set attribute to an XmlNode object which is not set to an instance or object. c#
body: <p>I cannot figure out how to set a default value to an <code>XmlNode</code>. </p>
  
  <p>I have an <code>XmlNode</code> called <code>RequirementMinTime</code> and I want to set it to the value of "0" when that node is not in the xml document. Here is the code I'm trying which is not working. </p>
  
  <pre><code>        XmlReader reader = XmlReader.Create(xmlpath, settings);
          XmlDocument doc = new XmlDocument();
  
          doc.Load(reader);
  
         if (GlobalNode.SelectSingleNode("MinTimeMs") == null)
          {
              RequirementMinTime.Attributes["MinTimeMs"].Value = "0";
          }
          else
          {
              RequirementMinTime = GlobalNode.SelectSingleNode("MinTimeMs");
          }
  </code></pre>
  
  <p>I am getting the following error in the if statement</p>
  
  <blockquote>
    <p>"System.NullReferenceException: 'Object reference not set to an
    instance of an object.'"</p>
  </blockquote>
  
  <p>this is the object declaration: </p>
  
  <pre><code>    public static XmlNode RequirementMinTime
      {
          get;
          set;
      }
  </code></pre>