How to deserialize Xml with root than multiple child elements of the same type

XRumerTest

New Member
I'm trying deserialize a xml document that looks like this\[code\]<invoices> <invoice>2848</invoice> <invoice>2849</invoice> <invoice>2850</invoice> <invoice>2851</invoice> <invoice>2852</invoice></invoices>\[/code\]Into a C# object, but I cannot get it to work. I'm using the \[code\]DataContractSerializer\[/code\]This is what my class looks like:\[code\][DataContract(Name = "invoices", Namespace = "")]public class Invoices{ [DataMember(Name = "invoice")] public Invoice[] InvoiceIds { get; set; }}[DataContract(Name = "invoice", Namespace = "")]public class Invoice{ [DataMember(Name = "invoice")] public string Id { get; set; }}\[/code\]Of course this does not work. I get this error:\[code\]{"Error in line 1 position 24. Expecting state 'Element'.. Encountered 'Text' with name '', namespace ''. "}\[/code\]I'm not in control of the Xml.
 
Back
Top