title: c# getting xml node that doesn't have close tag explicity
body: <p>this is my xml</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="utf-8" ?&gt; 
   &lt;SMS&gt;
    &lt;DeliveryDate&gt;6/27/2015 3:00:00 PM&lt;/DeliveryDate&gt; 
    &lt;Status&gt;DELIVRD&lt;/Status&gt; 
    &lt;Error /&gt; 
    &lt;/SMS&gt;
  </code></pre>
  
  <p>i want to know if the <strong>error</strong> node contains text or not</p>
  
  <p>i tried this:</p>
  
  <pre><code> XmlDocument doc = new XmlDocument();
                  doc.LoadXml(responseMessage);
                  string errorTagBody = doc.SelectSingleNode("ERROR").InnerText;
                  if (string.IsNullOrWhiteSpace(errorTagBody))
  </code></pre>
  
  <p>but i got this exception:</p>
  
  <pre><code>An unhandled exception of type 'System.NullReferenceException' occurred in TestStatus.exe
  
  Additional information: Object reference not set to an instance of an object.
  </code></pre>
  
  <p>on this line:</p>
  
  <pre><code>string errorTagBody = doc.SelectSingleNode("ERROR").InnerText;
  </code></pre>
  
  <p>not that sometimes, the xml could be like this:</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="utf-8" ?&gt; 
   &lt;SMS&gt;
    &lt;DeliveryDate&gt;6/27/2015 3:00:00 PM&lt;/DeliveryDate&gt; 
    &lt;Error&gt;Not formatted mobile number &lt;/ERROR&gt;
    &lt;/SMS&gt;
  </code></pre>