title: Get qualified name of an XML element and it's child nodes with C#
body: <p>Edited:</p>
  
  <p>I'm trying to accomplish three things here: get XmlNode Query, get the XmlNode QueryId and get the value of a:schemaLocation but the after parsing they end up as null. If I remove the qualified name from the XML, the C# bit works fine. How should I re-write my code?</p>
  
  <p>XML:</p>
  
  <pre><code>    &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:loc="localhost"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;loc:Service&gt;
           &lt;!--Optional:--&gt;
           &lt;loc:input&gt;?&lt;/loc:input&gt;
           &lt;Query a:schemaLocation="http://www.xyz.com/xml.xsd" xmlns:payload="http://www.xyz.com" xmlns:a="http://www.w3.org/2001/XMLSchema-instance" xmlns="loc4"&gt;
              &lt;QueryId&gt;Data&lt;/QueryId&gt;
           &lt;/Query&gt;
        &lt;/loc:Service&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>C#:</p>
  
  <pre><code>private NamespaceManager nsmgr;
  private XmlDocument doc = new XmlDocument();
  private Stream receiveStream = new Stream(HttpContext.Current.Request.InputStream);
  private XmlNode Query, QueryId;
  
  using (this.receiveStream){
  
  using (StreamReader readStream = new StreamReader(this.receiveStream, Encoding.UTF8)){
  
       doc.Load(readStream);
  
       this.nsmgr = new XmlNamespaceManager(this.doc.NameTable);
       this.nsmgr.AddNamespace("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
       this.nsmgr.AddNamespace("loc", "http://localhost");
       this.nsmgr.AddNamespace("schemaLocation", "http://www.xyz.com/xml.xsd");
       this.nsmgr.AddNamespace("payload", "http://www.xyz.com");
       this.nsmgr.AddNamespace("a", "http://www.w3.org/2001/XMLSchema-instance");
       this.nsmgr.AddNamespace("x", this.doc.DocumentElement.NamespaceURI);
       this.Query = doc.SelectSingleNode("//x:Query", this.nsmgr);
       this.QueryId= doc.SelectSingleNode("//x:QueryId", this.nsmgr);
       }
   }
  </code></pre>