adjunct.xmlutils¶
XML utilities.
XMLBuilder
¶
An XML document builder.
It's purposely namespace ignorant: it's up to user to supply appropriate
xmlns attributes as needed.
Examples:
>>> xml = XMLBuilder()
>>> with xml.within("root", xmlns="tag:talideon.com,2013:test"):
... xml += "Before"
... with xml.within("leaf"):
... xml += "Within"
... xml += "After"
... xml.tag("leaf", "Another")
>>> print xml.as_string()
<?xml version="1.0" encoding="utf-8"?>
<root xmlns="tag:talideon.com,2013:test">Before<leaf>Within</leaf>After<leaf>Another</leaf></root>
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out
|
TextIOBase | None
|
a file-like object to write the document to; if none is provided, a buffer is created. |
None
|
Note
If you provide your own, the as_string() method will return an empty
string as no other sensible value can be returned.