Sorry to bother you with such a simple question, but I'm stuck here for an hour:
I have an xml file that looks something like this:
<?xml version="1.0" encoding="utf-8"?> <aaa xmlns="http://blabla.com/xmlschema/v1"> <bbb> <ccc>Foo</ccc> </bbb> <ddd x="y" /> <ddd x="xx" /> <ddd x="z" /> </aaa>
I am trying to access ddd elements like this:
var doc = new XmlDocument(); doc.Load("example.xml"); foreach (XmlNode dddNode in doc.DocumentElement.SelectNodes("//ddd")) {
At run time, the foreach loop is skipped because I do not get any nodes from the .SelectNodes method. I broke through before the loop and looked at InnerXML, which looks great, and I also tried all kinds of XPaths (like "// bbb" or "/ aaa / ddd"), but only "/" does not seem to return zero.
This exact code worked for me before, now it is not. I suspect something with this namespace declaration in the aaa tag, but I could not understand why this should cause problems. Or ... can you see something that I might lose?
source share