The Xml response I receive is as follows:
<response>
<item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="java:com.someDomain.item">
<name>some name</disc-name>
<description>some description</disc-desc>
</item>
<item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="java:com.someDomain.item">
<name>some name</disc-name>
<description>some description</disc-desc>
</item>
<otherValue>12.1</otherValue>
</response>
My class is decorated as such:
[XmlElement("item")]
public Item[] Items{get;set;}
[XmlElement("otherValue")
public string OtherValue{get;set;}
When I attempt to deserialize the above Xml to the class described, I receive an error of "Namespace prefix 'java' is not defined". Adding the "namespace" attribute to the class resolves the parsing error(however, the xml is then distorted from the original).
ie
[XmlElement(ElementName="item",Namespace="java")]
How should I be decorating a given property to match up with a new namespace? Or, how do I correctly define the namespace?
I'm not 100% on using a stock array for my enumerable section either, but I think the namespace issue takes precident at the moment. Any insight or thoughts are greatly appreciated!
UPDATE:
I think the question is better rephrased now that I've gone back and forth a bit:
How do you use an XmlElementAttribute(or other attribute) to have a class that can serialize into the item snippet above, including the xsi tags?
As for my particular problem, I've realized since the Xml response is out of my control, I don't need the xsi attributes to begin with. To workaround the serialization issue, I'm simply doing the following(XmlElement element contains the original document above):
foreach(XmlNode node in element)
node.Attributes.RemoveAll();
I'm only noting my personal workaround as this is not actually a solution.