Guest User

Untitled

a guest
Jul 15th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. from xml.dom import minidom
  2.  
  3. doc = minidom.parse(myXmlFile)
  4. for element in doc.getElementsByTagName('MyElementName'):
  5. if element.getAttribute('name') in ['AttribName1', 'AttribName2']:
  6. element.parentNode.removeChild(element)
  7. f = open(myXmlFile, "w")
  8. f.write(doc.toxml())
  9. f.close()
  10.  
  11. from xml.dom import minidom
  12.  
  13. doc = minidom.parse(myXmlFile)
  14. for element in doc.getElementsByTagName('MyElementName'):
  15. if element.getAttribute('name') in ['AttrName1', 'AttrName2']:
  16. parentNode = element.parentNode
  17. parentNode.insertBefore(doc.createComment(element.toxml()), element)
  18. parentNode.removeChild(element)
  19. f = open(myXmlFile, "w")
  20. f.write(doc.toxml())
  21. f.close()
  22.  
  23. from BeautifulSoup import BeautifulSoup
  24. hello = "<!--Comment tag-->"
  25. commentSoup = BeautifulSoup(hello)
Add Comment
Please, Sign In to add comment