D
DimitrisV12
Guest
Hello guys. I am working in an project and I want to deserialize a huge xml file from api. The problem is this:
I have this XML Snippet:
<effectiveTime xsi:type="IVL_TS">
<low nullFlavor="UNK"/>
<high nullFlavor="UNK"/>
</effectiveTime>
<effectiveTime operator="A" xsi:type="PIVL_TS">
<period unit="h" value="12"/>
</effectiveTime>
As you can see is the same but those have different xsi:type attribute.
Well I create two classes to deserialize those.
[XmlType(TypeName = "IVL_TS")]
public class effectiveTime
{
[XmlElement("low")]
public low low { get; set; }
[XmlElement("high")]
public high high { get; set; }
}
[XmlType(TypeName = "PIVL_TS")]
public class _effectiveTime
{
[XmlAttribute(AttributeName = "operator")]
public string _operator { get; set; }
[XmlElement]
public period period { get; set; }
}
Here is the problem i tried something like this:
[XmlArrayItem(Type = typeof(effectiveTime))]
[XmlArrayItem(Type = typeof(_effectiveTime))]
public object[] effectiveTime { get; set; }
But when I deserialize the object the count of array is 0. What can i do?
Best regards.
Continue reading...
I have this XML Snippet:
<effectiveTime xsi:type="IVL_TS">
<low nullFlavor="UNK"/>
<high nullFlavor="UNK"/>
</effectiveTime>
<effectiveTime operator="A" xsi:type="PIVL_TS">
<period unit="h" value="12"/>
</effectiveTime>
As you can see is the same but those have different xsi:type attribute.
Well I create two classes to deserialize those.
[XmlType(TypeName = "IVL_TS")]
public class effectiveTime
{
[XmlElement("low")]
public low low { get; set; }
[XmlElement("high")]
public high high { get; set; }
}
[XmlType(TypeName = "PIVL_TS")]
public class _effectiveTime
{
[XmlAttribute(AttributeName = "operator")]
public string _operator { get; set; }
[XmlElement]
public period period { get; set; }
}
Here is the problem i tried something like this:
[XmlArrayItem(Type = typeof(effectiveTime))]
[XmlArrayItem(Type = typeof(_effectiveTime))]
public object[] effectiveTime { get; set; }
But when I deserialize the object the count of array is 0. What can i do?
Best regards.
Continue reading...