Let’s say I get two different xml documents from two different vendors using the same schema. They each chose different namespace prefixes. How can I query for the value of “Foo” and “Bar” in a generic fashion using XPATH in both C# and SQL Server? For brevity, The XML looks roughly like this:
Document 1
<a:Item xmlns:a="http://kakridge.com/schema">Foo</a:Item>
Document 2
<b:Item xmlns:b="http://kakridge.com/schema">Bar</a:Item>
XPath doesn’t care what prefixes appear in the source documents, it only cares about the namespace URI. If the prefix z is bound to the namespace http://kakridge.com/schema, then //z:Item will find the Item elements in both these documents.