lxml-wrapper 0.3.5
lxml wrapper that simplifies xml generation code.
This wrapper simplifies your Python xml generation code.
Example XML:
<root attrib="10">
text
<child attrib="">
childtext
</child>
tail
</root>
New way:
E('root', attrib=10).add(
'text',
E('child', attrib=None).add(
'childtext'),
'tail')
Old way:
root = Element('root', attrib=str(10)) # cast to str
root.text = 'text'
child = SubElement(root, 'child', attrib=value or "") # change None to empty string
child.text = 'childtext'
child.tail = 'tail'
Now with .add_if and .add_for methods:
E('root').add_if(1==1, E('child')) -> <root><child /></root>
E('root').add_if(1==0, E('child')) -> <root/>
E('root').add_for([1,2], lambda item: E('item', attr=item)) -> <root><item attr="1"/><item attr="2"/></root>
| File | Type | Py Version | Uploaded on | Size | # downloads |
|---|---|---|---|---|---|
|
lxml-wrapper-0.3.5.linux-i686.tar.gz
(md5)
built for Linux-2.6.32-27-generic-i686-with-glibc2.4 |
"dumb" binary | any | 2011-02-24 | 3KB | 351 |
| lxml-wrapper-0.3.5.tar.gz (md5) | Source | 2011-02-24 | 2KB | 329 | |
- Author: Mateusz `matee` Pawlik
- Home Page: http://github.com/matee911/lxml-wrapper
- Download URL: http://github.com/matee911/lxml-wrapper/downloads
- Keywords: lxml wrapper dsl
- License: BSD
- Platform: Any
- Requires lxml
- Categories
- Package Index Owner: matee.net
- DOAP record: lxml-wrapper-0.3.5.xml
