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:
<foo xmlns="uri" />
It appears as though some of the XPATH processor libraries won't recognize //foo 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.
Is there a standard that applies to this?
My approach is a bit hackish but it seems to work fine; I remove the xmlns declaration with a search/replace and then apply xpaths.
string readyForXpath = Regex.Replace( xmldocument, "xmlns=\".+\"", String.Empty );
Is that a fair approach or has anyone solved this differently?