I'm having some problem populating given below XML to class, I know how to populate class object from XML(Deserialization) but below XML is tricky for me.
<Header>
<To EmailType="Personal">[email protected]</To>
<From EmailType="Work">[email protected]</From>
</Header>
if I create below class, it will only populate the data part of the XML not the attribute,
[XmlRoot(ElementName = "Header")]
public class Header
{
public Header()
{
}
[XmlElement(ElementName = "To", Form = XmlSchemaForm.Unqualified)]
public string To { get; set; }
[XmlElement(ElementName = "From", Form = XmlSchemaForm.Unqualified)]
public string From { get; set; }
}
I want to be able to parse & save both attribute & data.