I am receiving some XML that looks like this.
<?xml version="1.0"?>
<parent xmlns="urn:place-com:spec.2004">
<childA xmlns="">123</childA>
<childB xmlns="">456</childB>
</parent>
I'm deserializing it into a class with C#'s XmlSerializer. It works, except the blank child namespaces are giving me trouble. Their properties in the class are null.
I understand the blank namespace puts the element in the global namespace. Probably not what is intended, but what I am receiving none the less.
If I manually delete the xmlns=""
attribute from the child element it works. If I fill out the attribute with xmlns="testNamespace"
and add the following attribute to the property in the class, it works.
[XmlElement(Namespace="testNamespace")]
public string childA
{ ... }
However, leaving the XML as is, and adding the following attribute does not work.
[XmlElement(Namespace="")]
How can I specify that an element has a blank namespace for deserialization?