|I'm trying to iterate the namespace declarations in an XML document so I can add them to the XmlNamespaceManager, but it's not working.
Given an XML document like:
<foo:bar xmlns:foo='the URI for foo' />
System.Xml.XmlDocument doc = new System.Xml.XmlDocument() ;
doc.Load ( args [ 0 ] ) ;
System.Xml.XmlNamespaceManager mgr = new System.Xml.XmlNamespaceManager ( doc.NameTable ) ;
foreach ( System.Xml.XmlNode nod in doc.SelectNodes ( "//*[@xmlns:*]" , mgr ) )
to select that element, but it doesn't.
Am I missing something? Does SelectNodes just not want to select by namespace attributes?
Edit: I now see that this is the defined behaviour of XPath 1.0; I don't like it, but there it is.
modified 29-Mar-12 18:00pm.