Skip to content

Instantly share code, notes, and snippets.

@mcantelon
Created March 5, 2013 22:11
Show Gist options
  • Save mcantelon/5094801 to your computer and use it in GitHub Desktop.
Save mcantelon/5094801 to your computer and use it in GitHub Desktop.
XML gen
from lxml import etree
stuff = {
"aaa": "bbb",
"ccc": "ddd"
}
# create XML
root = etree.Element('processingMCP')
choices = etree.Element('preconfiguredChoices')
root.append(choices)
for field in stuff:
value = stuff[field]
choice = etree.Element('preconfiguredChoice')
choice.text = value
choices.append(choice)
# pretty string
s = etree.tostring(root, pretty_print=True)
print s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment