Created
March 5, 2013 22:11
-
-
Save mcantelon/5094801 to your computer and use it in GitHub Desktop.
XML gen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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