I'm trying to write out a series of objects as an XML file so they can be read in later. I have all the code to build the XML tree and set all the attributes, etc. I've looked through the whole tree in VS so I know all of my data is there.
To write it to a file I use:
writer.WriteStartDocument();
writer.WriteStartElement("####");
node.WriteTo(writer);
writer.WriteEndElement();
writer.Close();
It works - mostly. The last child from most of the branches is missing it's last attribute. The final last child has all of it's attributes, but all the others are missing the last one.
Here is the output:
<Campaign Name="No Mercy">
<Level Name="The Apartments" Variants="2">
<Variant Mode="Coop" Map="l4d_hospital01_apartment" />
<Variant Mode="Versus" />
</Level>
<Level Map="The Subway" Variants="3">
<Variant Mode="Coop" Map="l4d_hospital02_subway" />
<Variant Mode="Versus" Map="l4d_vs_hospital02_subway" />
<Variant Mode="Survival" />
</Level>
<Level Map="The Sewers" Variants="3">
<Variant Mode="Coop" Map="l4d_hospital03_sewers" />
<Variant Mode="Versus" Map="l4d_vs_hospital03_sewers" />
<Variant Mode="Survival" />
</Level>
<Level Map="The Hospital" Variants="3">
<Variant Mode="Coop" Map="l4d_hospital04_interior" />
<Variant Mode="Versus" Map="l4d_vs_hospital04_interior" />
<Variant Mode="Survival" />
</Level>
<Level Map="The Rooftop" Variants="3">
<Variant Mode="Coop" Map="l4d_hospital05_rooftop" />
<Variant Mode="Versus" Map="l4d_vs_hospital05_rooftop" />
<Variant Mode="Survival" Map="l4d_vs_hospital05_rooftop" />
</Level>
</Campaign>
The last variant node on each Level node is missing the Map attribute. Except for the final one. Any ideas?