[XML-SIG] How to Parse XML with Single Element & Multiple Attribures
Stefan Behnel
stefan_ml at behnel.de
Fri Aug 1 11:07:50 CEST 2008
Hi,
tjabaut wrote:
> I have an app where the API returns an XML state with a single element
> that contains a number of attributes (depending on which API is
> called).
>
> I would like ot know how I can step through these Attributes so that I
> can populate an XHTML results page.
# using Python 2.5
from xml.etree import ElementTree
tree = ElementTree.fromstring(the_xml_string)
root = tree.getroot()
# and now using the dict-like attrib property:
for name, value in root.attrib.items():
print name, value
Stefan
More information about the XML-SIG
mailing list