I've been using the answer here binding xml elements to model in MVC4 to bind an XML file to a model.
This works fine when the XML file has one element. I need to handle the case when there are many elements. I'd like all of those elements to go into a List.
Here's an example file:
<root>
<item>
<firstname>Tom</firstname>
</lastname>Jones</lastname>
<item>
<item>
<firstname>Jane</firstname>
</lastname>Doe</lastname>
</item>
</root>
MyXMLElements class looks like:
[Serializable]
[XmlRoot("item")]
public class MyXMLElements
{
public string first name {get;set;}
public string lastname {get;set;}
}
How I do I create a List<MyXMLElements>
?