@@ -4,38 +4,39 @@ A library providing python bindings for rapidxml
44
55### Example
66
7- import rapidxml
7+ ``` python
8+ import rapidxml
89
9- r = rapidxml.RapidXml(b"<test/><test2>foo</test2><test></test>") # parsing from bytes
10- test = r.first_node("test") # get first node named test
11- test.name = "foo" # changing node's name to foo
12- r.first_node("test2").value = "bar" # changing node's value to bar
10+ r = rapidxml.RapidXml(b " <test/><test2>foo</test2><test></test>" ) # parsing from bytes
11+ test = r.first_node(" test" ) # get first node named test
12+ test.name = " foo" # changing node's name to foo
13+ r.first_node(" test2" ).value = " bar" # changing node's value to bar
1314
14- print(str(r)) # will output a prettified string of the xml document
15- print(r.unparse(pretty=False, raw=True)) # will output the xml document as flat bytes
16- print(test) # also works for nodes
15+ print (str (r)) # will output a prettified string of the xml document
16+ print (r.unparse(pretty = False , raw = True )) # will output the xml document as flat bytes
17+ print (test) # also works for nodes
1718
18- with open('dump.xml', 'w') as f:
19- f.write(str(r))
20- r = rapidxml.RapidXml("dump.xml", True) # loading from file
21-
22- assert(str(r) == r.unparse(True, False)) # is always True
23- assert(repr(r) == r.unparse(pretty=False, raw=False)) # also always True
19+ with open (' dump.xml' , ' w' ) as f:
20+ f.write(str (r))
21+ r = rapidxml.RapidXml(" dump.xml" , from_file = True ) # loading from file
2422
23+ assert (str (r) == r.unparse(True , False )) # is always True
24+ assert (repr (r) == r.unparse(pretty = False , raw = False )) # also always True
25+ ```
2526
2627### Install
2728
28- [ ![ Latest Version] ( https://pypip.in/version/RapidXml/badge .svg )] ( https://pypi.python.org/pypi/RapidXml/ )
29- [ ![ Supported Python Versions] ( https://pypip.in/py_versions/RapidXml/badge .svg )] ( https://pypi.python.org/pypi/RapidXml/ )
29+ [ ![ Latest Version] ( https://img.shields.io/pypi/v/RapidXml .svg )] ( https://pypi.python.org/pypi/RapidXml/ )
30+ [ ![ Supported Python Versions] ( https://img.shields.io/pypi/pyversions/RapidXml .svg )] ( https://pypi.python.org/pypi/RapidXml/ )
3031
3132If you have downloaded the source code:
32-
33+ ``` sh
3334 python setup.py install
34-
35+ ```
3536or if you want to obtain a copy from the Pypi repository:
36-
37+ ``` sh
3738 pip install rapidxml
38-
39+ ```
3940Both commands will install the required package dependencies.
4041
4142A distribution package can be obtained for manual installation at:
@@ -46,9 +47,9 @@ A distribution package can be obtained for manual installation at:
4647### Source
4748
4849python_rapidxml's git repo is available on GitHub, which can be browsed at [ github] ( https://github.com/Arzaroth/python_rapidxml ) and cloned like that:
49-
50+ ``` sh
5051 git clone https://github.com/Arzaroth/python_rapidxml.git
51-
52+ ```
5253
5354### License
5455
0 commit comments