title: XPATHS and Default Namespaces
body: <p>What is the story behind XPath and support for namespaces? Did XPath as a specification precede namespaces?  If I have a document where elements have been given a default namespace: </p>
  
  <pre><code>&lt;foo xmlns="uri" /&gt;
  </code></pre>
  
  <p>It appears as though some of the XPath processor libraries won't recognize <code>//foo</code> because of the namespace whereas others will. The option my team has thought about is to add a namespace prefix using regular expressions to the XPath (you can add a namespace prefix via XmlNameTable) but this seems brittle since XPath is such a flexible language when it comes to node tests.</p>
  
  <p>Is there a standard that applies to this?</p>
  
  <p>My approach is a bit hackish but it seems to work fine; I remove the <code>xmlns</code> declaration with a search/replace and then apply XPath.</p>
  
  <pre><code>string readyForXpath = Regex.Replace(xmldocument, "xmlns=\".+\"", String.Empty );
  </code></pre>
  
  <p>Is that a fair approach or has anyone solved this differently?</p>