Python script to remove all comments from XML file
- by Jennifer Greentree
I am trying to build a python script that will take in an XML document and remove all of the comment blocks from it.
I tried something along the lines of:
tree = ElementTree()
tree.parse(file)
commentElements = tree.findall('//comment()')
for element in commentElements:
element.parentNode.remove(element)
Doing this yields a weird error…