tags:

views:

16

answers:

1

Hi,

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.CreateNavigator().Select("//*/namespace-uri(.)").Dump();
// the error below.
XPathException: ('//*/namespace-uri(.)' has an invalid token)

Thanks

A: 

Hi,

For anyone else trying this here is the code that works.

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

Regards

Me

Jim