Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from xml.dom import minidom
- doc = minidom.parse(myXmlFile)
- for element in doc.getElementsByTagName('MyElementName'):
- if element.getAttribute('name') in ['AttribName1', 'AttribName2']:
- element.parentNode.removeChild(element)
- f = open(myXmlFile, "w")
- f.write(doc.toxml())
- f.close()
- from xml.dom import minidom
- doc = minidom.parse(myXmlFile)
- for element in doc.getElementsByTagName('MyElementName'):
- if element.getAttribute('name') in ['AttrName1', 'AttrName2']:
- parentNode = element.parentNode
- parentNode.insertBefore(doc.createComment(element.toxml()), element)
- parentNode.removeChild(element)
- f = open(myXmlFile, "w")
- f.write(doc.toxml())
- f.close()
- from BeautifulSoup import BeautifulSoup
- hello = "<!--Comment tag-->"
- commentSoup = BeautifulSoup(hello)
Add Comment
Please, Sign In to add comment