Im trying to post data to a web application that only accepts XML. I have created the objects in c# (as below) and am using the XmlSerializer to serialize the object to XML but cannot work out how to structure the objects in order to get the resulting XML that the receiving application requires:
The REQUIRED resulting XML
<recipients>
<gsm messageId="clientmsgID1">number1</gsm>
<gsm messageId="clientmsgID2">number2</gsm>
<gsm messageId="clientmsgID3">number3</gsm>
<gsm messageId="clientmsgID4">number4</gsm>
</recipients>
My objects
public class recipients
{
public List<gsm> gsm{ get; set; }
public recipients()
{
gsm = new List<gsm>();
}
}
public class gsm
{
[XmlText]
public string number { get; set; }
[XmlAttribute]
public string messageId{ get; set; }
}
My resulting XML
<recipients>
<gsm>
<gsm messageId="clientmsgID1">number1</gsm>
</gsm>
</recipients>