xml

I had to work most of the time since the competition started but the next few days are dedicated for pure pyweek Added some selectable options on the title screen, including a function to scan any available level files and let you choose one Wrote most of the class to load a level xml file and parse it Still using a hardcoded test level, need to switch it to the new xml format to test it out Next ----- Render the loaded xml level Add collision code for loaded objects and platforms Create a level editor for the xml files then can start adding enemies, objects and possibly objectives

(log in to comment)

Comments

Sounds like good progress!
what are you using for your xml library? My group is using xml to describe the levels as well, with lxml being the library to handle parsing (which has a really feature rich xpath implementation and more)... Cheers!
xml.sax to parse it. First time I've set it up from scratch so had a few glitches. It uses an eventHandler to trigger a function at the start of each element and end of each element, so its not as straightforward as I hoped.
My only other experience with xml is the PHP library for it, which can parse Xpath expressions, I like that a bit more.

I worked a little more before sleeping and got it parsing and rendering the test level to the screen
Working on collision code now cause whatever I did last night is completely buggy
if you want good xpath support check out lxml (if you have setuptools installed, you can use `easy_install lxml==1.3bugfix` to install it). To use xpath it's as easy as doing:
xml file:
--------------
<root>
  <a>
    <b attr="xyz">abc</b>
    <c attr="abc">def</c>
  </a>
</root>
-----------------------

and in your code, something like:

------------------------------
from lxml import etree

tree = etree.parse('./level.xml')
b = tree.xpath('/root/a/b/text()')
c_attr = tree.xpath('/root/a/c/@attr')
-------------------------------


cheers!
Please just stick to the libraries that come with Python. ElementTree for example is a very nice API that (I believe) has xpath. You need to be using Python 2.5 though to have it built in. Otherwise there's plenty of other XML functionality built into Python2.4.
I'll definitely check out lxml or ElementTree after this. I got xml.sax working well and it turns out that it made creating a map editor much easier since I had to create a set of objects to handle each element anyways. I'm using Python 2.5.1 so I'm not sure what differences there are with those libraries and previous versions