For example, If I have a list with two objects and I want to put them into an XML file using Xelement and trying to loop through the objects it put's the second object items into the first Xelement name because they have the same Xelement tagname.
How can I tell an Xelement that it needs to be unique in some kind? So it won't put the second object in the first people tag but in the second.
List<People> people -> has two items
foreach (var person in people)
{
xmlDoc.Element("people").Add(new XElement("person"............
}
example of XML output:
<people>
<person></person>
<person></person>
</people>
<people>
</people>
Never mind I've found the answer.
Using Element will give you the first element he can find in your XML document.
using Elements("people").Last().Element("person").Add
will give you the last one in the collection. As I am looping though the objects the last one will always be the one i'm in at that moment.
Thanks anyway.