calling namespace-uri in C#, namespace-uri has an invalid token
I am executing the following. Given an XDocument doc;
doc.XPathEvaluate("//namespace-uri()");
I get the error '//namespace-uri()' has an invalid token.
It seems to work in a node test, for example "//*[namespace-uri()='xyz']". The function should work though, XMLSPY is happy with the above version, and I believe it uses the same engine.
Any help would be appreciated. I want to enumerate all the namespaces in the docume开发者_如何学编程nt using xpath.
Thanks Regards Craig.
Your XPath is wrong. The namespace-uri()
function returns a string, so it can't be used where a nodeset is expected. Instead, you should use the namespace
axis:
doc.XPathEvaluate("//namespace::*");
This will return a nodeset containing every namespace declaration in the document.
精彩评论