var count = (from p in xmlDoc.Descendants("env:SE04Overprinting")
select p).Count();
throws an exception (kind of, it crashes out when getting there, but using a watch shows this error)
xmlDoc.Descendants("env:SE04Overprinting")
‘”env:SE04Overprinting”‘ threw an exception of type ‘System.Xml.XmlException’
System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement>
I did a bit of looking around on this error but didn’t find anything, then tried getting rid of the colon:
var count = (from p in xmlDoc.Descendants("env")
select p).Count();
this works. Is stripping the colons out of the file the only way around this?
If your XML properly declares the namespace you can do this:
Example:
Since
baris within theenvnamespace you can retrieve its value like this:Make sure the
XNamespacedeclaration matches exactly the value of the namespace within your XML.