Reputation: 53
I want to Deserialize two different kind of Xml elements into one List as I want to preserve the order
<Step name="Login to Account" >
<Action name="LoginToWebsite" type="Login" />
<NewAction name="EnterTextInTextBox" type="SendKeysToTextBox" extraAttribute="Testvalue" />
</Step>
currently I am using the following to get the two actions into one list but I have to change the element name to NewAction (like above) instead of Action for the second one
[XmlRoot(ElementName = "Step")]
public class WorkflowStep
{
[XmlAnyElement("Action")]
public XmlElement[] Actions
{
get;
set;
}
}
As the XmlAnyElement is bound to "Action" Element name, how can I change to support two different Element Names but need to be Deserialized into one array
Upvotes: 0
Views: 287
Reputation:
What you want is
[XmlRoot(ElementName = "Step")]
public class WorkflowStep
{
[XmlAnyElement("Action")]
[XmlAnyElement("NewAction")]
public XmlElement[] Actions
{
get;
set;
}
}
Upvotes: 1