Mega Code Archive

 
Categories / Python Tutorial / XML
 

Removing a Node from a DOM Tree

from xml.dom  import minidom xmldoc = minidom.parse('stations.xml') doc_root = xmldoc.documentElement nodeList = xmldoc.childNodes for node in nodeList:     print node.toprettyxml() doc_root.removeChild(doc_root.childNodes[0]) nodeList = xmldoc.childNodes for node in nodeList:     print node.toprettyxml()