How do I have LINQ to XML iqnore all namespaces? Or alteranately, how to I strip out the namespaces?
I’m asking because the namespaces are being set in a semi-random fashion and I’m tired of having to search for nodes both with and without a namespace.
Instead of writing:
write:
and when you get tired of it, make your own extension method:
Ditto for attributes, if you have to deal with namespaced attributes often (which is relatively rare).
[EDIT] Adding solution for XPath
For XPath, instead of writing:
you can use
local-name()function: