Simon Pickles schrieb: > Hi > > Can anyone suggest a really simple XML reader for python? I just want to > be able to do something like this: > > xmlDoc = xml.open("file.xml") > element = xmlDoc.GetElement("foo/bar") > > ... to read the value of: > > <foo> > <bar>42</bar> > </foo>
Since python2.5, the ElementTree module is available in the standard lib. Before 2.5, you can of course install it. Your code then would look like this: import xml.etree.ElementTree as et doc = """ <foo> <bar>42</bar> </foo> """ root = et.fromstring(doc) for bar in root.findall("bar"): print bar.text Diez -- http://mail.python.org/mailman/listinfo/python-list