justaman08
New Member
I have an XML file that looks like this:\[code\]<Contacts> <Person name="James" id"=1" /> <Person name="Edward" id"=2" /></Contacts>\[/code\]I want to do something, so if ID=2, create 10 more Persons and update their ID's and names, this way:\[code\]if (person.ID == 2){ foreach (var item in duplicatePersons) { pers.SetAttributeValue("id", item.Key); pers.SetAttributeValue("name", item.Value); allPersons.Add(pers); }}\[/code\]duplicatePersons is a dictionary that contains all the duplicate persons.The problem is, that the first iteration of this foreach loop is creating:\[code\]<Person name="Josh" id"=3" />\[/code\]After the second iteration, it should look like:\[code\]<Person name="Josh" id"=3" /><Person name="Jacob" id"=4" />\[/code\]But it looks like:\[code\]<Person name="Jacob" id"=4" /><Person name="Jacob" id"=4" />\[/code\]So the 2nd iteration updates both the first and second elements.Any idea why?