merge with geni_api branch
[sfa.git] / xmlbuilder-0.9 / xmlbuilder.egg-info / PKG-INFO
1 Metadata-Version: 1.0
2 Name: xmlbuilder
3 Version: 0.9
4 Summary: Pythonic way to create xml files
5 Home-page: http://pypi.python.org/pypi/xmlbuilder
6 Author: koder
7 Author-email: koder_dot_mail@gmail_dot_com
8 License: MIT
9 Download-URL: http://pypi.python.org/pypi/xmlbuilder
10 Description: Example of usage:
11         -----------------
12         
13         
14         from __future__ import with_statement
15         from xmlbuilder import XMLBuilder
16         x = XMLBuilder(format=True)
17         with x.root(a = 1):
18         with x.data:
19         [x << ('node',{'val':i}) for i in range(10)]
20         
21         print str(x)
22         
23         will print
24         
25         <root a="1">
26         <data>
27         <node val="0" />
28         <node val="1" />
29         <node val="2" />
30         <node val="3" />
31         <node val="4" />
32         <node val="5" />
33         <node val="6" />
34         <node val="7" />
35         <node val="8" />
36         <node val="9" />
37         </data>
38         </root>
39         
40         Mercurial repo:http://hg.assembla.com/MyPackages/
41         
42         Documentations
43         --------------
44         `XMLBuilder` is simple library build on top of `ElementTree.TreeBuilder` to
45         simplify xml files creation as much as possible. Althow it can produce
46         structured result with identated child tags. `XMLBuilder` use python `with`
47         statement to define xml tag levels and `<<` operator for simple cases -
48         text and tag without childs.
49         
50         First we need to create xmlbuilder
51         
52         from xmlbuilder import XMLBuilder
53         # params - encoding = 'utf8',
54         # builder = None, - ElementTree.TreeBuilder
55         # tab_level = None, - current tab l;evel - for formatted output only
56         # format = False, - create formatted output
57         # tab_step = " " * 4 - indentation step
58         xml = XMLBuilder()
59         
60         
61         Use `with` statement to make document structure
62         #create and open tag 'root_tag' with text 'text' and attributes
63         with xml.root_tag(text,attr1=val1,attr2=val2):
64         #create and open tag 'sub_tag'
65         with xml.sub_tag(text,attr3=val3):
66         #create tag which are not valid python identificator
67         with xml('one-more-sub-tag',attr7=val37):
68         xml << "Some textual data"
69         #here tag 'one-more-sub-tag' are closed
70         #Tags without children can be created using `<<` operator
71         for val in range(15):
72         xml << ('message',"python rocks!"[:i])
73         #create 15 child tag like <message> python r</message>
74         #all tags closed
75         node = ~x # get etree.ElementTree object
76         xml_data = str(x)
77         unicode_xml_data = unicode(x)
78         
79 Keywords: xml
80 Platform: UNKNOWN