I've the following structure:
<Root name="jack">
<Ele1>4</Ele1>
<Ele2>4</Ele2>
<Ele3>4</Ele3>
<Ele4>4</Ele4>
</Root>
I want to modify some values so I use the following code:
XElement root1 = new XElement("Root");
root1.SetAttributeValue("name", "jack");
root1.SetElementValue("Ele1", 1);
root1.SetElementValue("Ele2", 2);
root1.SetElementValue("Ele3", 3);
The result of this is a new structure:
<Root name="jack">
<Ele3>3</Ele3>
</Root>
If I print root1 Debug.Log(root1)
after setting the value of Ele2 the result is:
<Root name="jack">
<Ele2>2</Ele2>
</Root>
Respectively if I do after setting the value of Ele1.
I'm using C# & MonoDevelop for Unity3D.
` tags, the formatting is distinctly worse.
– Jon Skeet Oct 17 '14 at 17:06