title: C# XPathSelectElement and xml with attribute xmlns="http://www.w3.org/2000/09/xmldsig#" Help
body: <p>I need to read an xml element which has attribute xmlns="http://www.w3.org/2000/09/xmldsig#".
  XPathSelectElement is giving error "Object reference not set to an instance of an object."</p>
  
  <p>Here is the sample code.</p>
  
  <pre><code>var xml = "&lt;root&gt;&lt;tagA&gt;Tag A&lt;/tagA&gt;&lt;tagB&gt;Tag B&lt;/tagB&gt;&lt;/root&gt;";
  XDocument xd = XDocument.Parse(xml);
  var str = xd.XPathSelectElement("/root/tagB").ToString(SaveOptions.DisableFormatting);
  Console.WriteLine(str);
  </code></pre>
  
  <p>The result of the above code is:</p>
  
  <pre><code>&lt;tagB&gt;Tag B&lt;/tagB&gt;
  </code></pre>
  
  <p>If I put attribute,</p>
  
  <pre><code>var xml = "&lt;root&gt;&lt;tagA&gt;Tag A&lt;/tagA&gt;&lt;tagB xmlns=\"http://www.w3.org/2000/09/xmldsig#\"&gt;Tag B&lt;/tagB&gt;&lt;/root&gt;";
  </code></pre>
  
  <p>I got error. </p>
  
  <pre><code>Object reference not set to an instance of an object.
  </code></pre>
  
  <p>Am I missing something here? Can anyone please help me out. (I know I can get by using other methods. I just want to know what I am missing here)</p>
  
  <p>Thank you very much.</p>