Given the following XML markup:
<root xmlns="Demo">
<child name="foo"/>
</root>
and an XPathNavigator
positioned on the <child>
element,
string withNs = navigator.GetAttribute("name", navigator.NamespaceURI);
string withoutNs = navigator.GetAttribute("name", "");
produce strange results: withNs
is empty, withoutNs
contains foo
.
Why is that? I would have expected it would be the other way round, as the name
attribute must be in the Demo
namespace like the child
element.
The MSDN documentation does not mention any magic meaning of passing namespaceURI=""
, so I assumed you have to pass the real namespace URI of the attribute.