CreateNavigator(X-Path包含无效令牌)

时间:2010-07-16 07:44:31

标签: c# xml xpath

我试图使用XPath枚举文档中的所有命名空间。 以下适用于xmlspy,但不适用于.NET

//*/namespace-uri(.)

// Executing this in linqpad, I get the error below.
xml.CreateNavigator().Select("//*/namespace-uri(.)").Dump();
// the error below.
XPathException: ('//*/namespace-uri(.)' has an invalid token)

由于

1 个答案:

答案 0 :(得分:0)

对于其他在这里尝试此操作的人来说,代码是有效的。

(element.XPathEvaluate("//namespace::*") as IEnumerable).OfType<XAttribute>().Distinct()

此致

相关问题