Created
January 5, 2015 18:33
-
-
Save diminoten/bf4af61398689464f2d3 to your computer and use it in GitHub Desktop.
This file contains 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
import lxml.builder as builder | |
from lxml import etree | |
foo = builder.E.foo | |
bar = builder.E.bar | |
bing = builder.E.bing | |
foo_xml = foo( | |
bar( | |
bing("Some nested thing."), | |
more="nested things", | |
even="more nested things" | |
), | |
attribute_one="animal", | |
attribute_two="plant", | |
xmlns="https://url.to.github.project" | |
) | |
print etree.tostring(foo_xml, pretty_print=True) |
The problem might arise if I needed to set one of my element tag names to a keyword, e.g.:
set = builder.E.set
set_xml = set(
attribute="foo"
)
But I think I can just do this:
different_set = builder.E.set
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Comes out as: