I should begin by stating that XML and I don't seem to get along very well. I've just about finished the interface on the level editor for a game I've made, and the next step is generating a XML file so that it can be read into the game dynamically.
The problem is, well, the XML. I've been fighting it for the past hour or two, and still can't achieve what I would like.
This may not be valid XML, but it is a good idea of what I would like to achieve:
<root>
<containers>
<container>
<name>Unsorted Objects</name>
<children>
<object>
<name>Img1 - container 1</name>
<x>420</x>
</object>
<object>
<name>Img2 - container 1</name>
<x>902</x>
</object>
</children>
</container>
<container>
<name>Special Objects</name>
<children>
<object>
<name>Spcl1 - container 2</name>
<x>420</x>
</object>
<object>
<name>Spcl2 - container 2</name>
<x>902</x>
</object>
</children>
</container>
</containers>
</root>
Anyways, what libraries would you all suggest to write XML like this and then, later, parse it? I've tried ElementTree, and I seem to like it, but I just can't do what I want to. Sure, those examples with two objects each with two properties are nice and pretty, but none had the same level of depth as my XML shown above, leaving me confused. When I try to extend them, I keep getting None as the return value for my calls.
If somebody could just give me a little code sample explaining on how to parse/write XML at this level of depth, I would really appreciate it.
Thanks so much in advance.