python rapidxml库
RapidXml的Python项目详细描述
为rapidxml提供python绑定的库
示例
importrapidxmlr=rapidxml.RapidXml(b"<test/><test2>foo</test2><test></test>")# parsing from bytestest=r.first_node("test")# get first node named testtest.name="foo"# changing node's name to foor.first_node("test2").value="bar"# changing node's value to barprint(str(r))# will output a prettified string of the xml documentprint(r.unparse(pretty=False,raw=True))# will output the xml document as flat bytesprint(test)# also works for nodeswithopen('dump.xml','w')asf:f.write(str(r))r=rapidxml.RapidXml("dump.xml",from_file=True)# loading from fileassert(str(r)==r.unparse(pretty=True,raw=False))# is always Trueassert(repr(r)==r.unparse(pretty=False,raw=False))# also always True
安装
如果您下载了源代码:
python setup.py install
或者,如果您想从PYPI存储库获取副本:
pip install rapidxml
这两个命令都将安装所需的包依赖项。
可在以下位置获取分发包以进行手动安装:
http://pypi.python.org/pypi/RapidXml
来源
python_rapidxml的git repo在github上可用,可以浏览 在github和克隆 像这样:
git clone https://github.com/Arzaroth/python_rapidxml.git
许可证
麻省理工学院执照。请参阅许可证文件。