So I'm trying to parse an xml file:
<?xml version="1.0" encoding="utf-8" ?>
<Root>
<att1 name="bob" age="unspecified" xmlns="http://foo.co.uk/nan">
</att1>
</Root>
Using the following code:
XElement xDoc= XElement.Load(filename);
var query = from c in xDoc.Descendants("att1").Attributes() select c;
foreach (XAttribute a in query)
{
Console.WriteLine("{0}, {1}",a.Name,a.Value);
}
Nothing is written to the console unless I delete xmlns="http://foo.co.uk/nan" from the xml file, after which, I get a list of attribute names and values as one would expect, and as I need!
Edit: Formatting.