I have the following XML that I am trying to parse
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:IntegrationActionResponse xmlns:ns2="example.com">
<ActionResults>
<SuccessCount>1</SuccessCount>
<FailureCount>0</FailureCount>
<ActionResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:ParameterizedIntegrationActionResult">
<Status>OK</Status>
<resultParams>
<entry>
<key>abc</key>
<value>abc</value>
</entry>
<entry>
<key>abc</key>
<value>abc</value>
</entry>
<entry>
<key>abc</key>
<value>abc</value>
</entry>
</resultParams>
</ActionResult>
</ActionResults>
</ns2:IntegrationActionResponse>
I'm trying to deserialize it using this model class
using System.Collections.Generic;
using System.Xml.Serialization;
{
[XmlRoot(
IsNullable = false,
ElementName = "IntegrationActionResponse",
Namespace = "example.com"
)]
public class LoadIActionResponseModel
{
[XmlElement("ActionResults", Namespace = "")]
public LoadIActionResults ActionResults { get; set; }
}
public class LoadIActionResults
{
[XmlElement(ElementName = "SuccessCount")]
public int SuccessCount { get; set; }
[XmlElement(ElementName = "FailureCount")]
public int FailureCount { get; set; }
[XmlType(TypeName = "ParameterizedIntegrationActionResult", Namespace = "http://www.w3.org/2001/XMLSchema-instance")]
public LoadIActionResult ActionResult { get; set; }
}
public class LoadIActionResult
{
[XmlElement(ElementName = "Status")]
public string Status { get; set; }
[XmlElement(ElementName = "resultParams")]
public LoadIActionResultParams resultParams {get; set;}
}
public class LoadIActionEntry
{
[XmlElement(ElementName = "key")]
public string Key { get; set; }
[XmlElement(ElementName = "value")]
public string Value { get; set; }
}
public class LoadIActionResultParams
{
[XmlElement(ElementName = "entry")]
public List<LoadIActionEntry> Entries { get; set; }
}
}
The root node is being deserialized ok. I have tried using the XmlType annotation to parse out the attributes, but the ActionResult returns null. How do I build my model class to accept the xlmns and xsi attributes on the ActionResult node?