title: Read SOAP Message and insert the data into a variable
body: <pre><code>&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:ns1=&quot;https://webservice.someWebService.php&quot;&gt;
      &lt;SOAP-ENV:Body&gt;
          &lt;ns1:loginResponse&gt;
              &lt;return&gt;
                  &lt;errorCode&gt;OK&lt;/errorCode&gt;
                  &lt;header&gt;
                      &lt;sessionToken&gt;tokentokentokentokentokentokentokentokentoken&lt;/sessionToken&gt;
                      &lt;errorCode&gt;OK&lt;/errorCode&gt;
                  &lt;/header&gt;
              &lt;/return&gt;
          &lt;/ns1:loginResponse&gt;
      &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  <p>I am trying to get the sessionToken from the XML above and place it into a string variable.</p>
  <p>This is the code that i have tried:</p>
  <pre><code>            string soapmessage = response.Content;
  
              XmlDocument document = new XmlDocument();
              document.LoadXml(soapmessage);  //loading soap message as string 
              XmlNamespaceManager manager = new XmlNamespaceManager(document.NameTable);
  
              manager.AddNamespace(&quot;d&quot;, &quot;http://someURL&quot;);
              manager.AddNamespace(&quot;bhr&quot;, &quot;https://webservice.someWebService.php&quot;);
  
              XmlNodeList xnList = document.SelectNodes(&quot;//bhr:loginResponse&quot;, manager);
              int nodes = xnList.Count;
              string Status;
              foreach (XmlNode xn in xnList)
              {
                  Status = xn[&quot;d:sessionToken&quot;].InnerText;
              }
  </code></pre>
  <p>But im getting an error of
  <strong><code>System.NullReferenceException: 'Object reference not set to an instance of an object.'</code></strong></p>