开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜