Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. from xml.etree.cElementTree import Element, ElementTree
  2. rootEm = Element("root")
  3. childEm1 = Element("child1")
  4. rootEm.append(childEm1)
  5. childEm2 = Element("child2")
  6. rootEm.append(childEm2)
  7. ElementTree(root).write(filename)
  8.  
  9. import SOMEXMLWRITER
  10. _f = open(filename, "w") ## open file first
  11. writer = SOMEXMLWRITER(_f)
  12. rootEm = Element("root") ## add Element at that time
  13. writer.addXMLDocument(rootEm)
  14. childEm1 = Element("child1")
  15. rootEm.append(childEm1)
  16. childEm2 = Element("child2")
  17. rootEm.append(childEm2)
  18. _f.close() ## just close file... DONE!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement