Return to Snippet

Revision: 17548
at September 9, 2009 11:22 by manatlan


Initial Code
#from elementtree.etree importe ElementTree
from xml.etree import ElementTree

#a=ElementTree.parse("toto.xml")
a=ElementTree.fromstring("<a>fds</a>")

b=ElementTree.XML("<b/>")
a.append(b)

b=ElementTree.Element("b",{"key":"value"})
b.text = "kiki"
b.set("toto","tata")
a.append(b)


print ElementTree.tostring(a,encoding="Windows-1252")

for i in a.findall("b"):
    print i,i.get("key")

Initial URL

                                

Initial Description

                                

Initial Title
Elementtree use cases

Initial Tags
python, xml

Initial Language
Python