/ Published in: Python
![](/img/icon_sav.png?v3)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#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")
Comments
![RSS Feed for Comments RSS Icon](/images/rss.png?v3)