Revision: 17547
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 9, 2009 11:21 by manatlan
Initial Code
from xml.dom import minidom #doc = minidom.parse(file) doc = minidom.parseString("<a>hello</a>") print doc.toprettyxml(encoding="utf-8") node=doc.createElement("b") node.setAttribute("nom","val") doc.documentElement.appendChild(node) node2=doc.createTextNode("koko") doc.documentElement.appendChild(node2) print doc.toprettyxml(encoding="utf-8") for i in doc.documentElement.childNodes: print i,i.nodeType #(i.ELEMENT_NODE,i.TEXT_NODE) for i in doc.getElementsByTagName("a"): print "-<A>-",i node.parentNode.removeChild(node) node2.parentNode.removeChild(node2) print doc.toprettyxml(encoding="utf-8")
Initial URL
Initial Description
Initial Title
minidom use cases
Initial Tags
python, xml
Initial Language
Python