Skip to content

Instantly share code, notes, and snippets.

@nkabir
Created October 16, 2011 13:25
Show Gist options
  • Save nkabir/1290874 to your computer and use it in GitHub Desktop.
Save nkabir/1290874 to your computer and use it in GitHub Desktop.
Gist for Praxis Documentation
import elementtree.ElementTree as ET
# build a tree structure
root = ET.Element("html")
head = ET.SubElement(root, "head")
title = ET.SubElement(head, "title")
title.text = "Page Title"
body = ET.SubElement(root, "body")
body.set("bgcolor", "#ffffff")
body.text = "Hello, World!"
# wrap it in an ElementTree instance, and save as XML
tree = ET.ElementTree(root)
tree.write("page.xhtml")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment