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">abc@abc.com</To>
<From EmailType="Work">abc2@abc.com</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.