2010-07-16 23 views
0

我想枚舉使用XPath的文檔中的所有名稱空間。 在XMLSpy的以下作品,但不是在.NETCreateNavigator(X-Path具有無效標記)

//*/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) 

感謝

回答

0

爲別人想這是這裏的作品的代碼。

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

問候