CreateNavigator (X-Path has invalid token)
I am trying to enumerate all the namespaces in a document using XPath. The following works in xmlspy, but not in .NET
//*/namespace-uri(.)
// Executing this in linqpad, I get the error below.
xml.CreateNaviga开发者_如何学Gotor().Select("//*/namespace-uri(.)").Dump();
// the error below.
XPathException: ('//*/namespace-uri(.)' has an invalid token)
Thanks
For anyone else trying this here is the code that works.
(element.XPathEvaluate("//namespace::*") as IEnumerable).OfType<XAttribute>().Distinct()
Regards
Me
精彩评论