If I m parsing an XML document using lxml, is it possible to view a text representation of an element? I tried to do :
print repr(node)
但产出
<Element obj at b743c0>
我可以怎样看待在XML档案中存在的问题? 是否有某种<条码>至_xml方法或东西?
If I m parsing an XML document using lxml, is it possible to view a text representation of an element? I tried to do :
print repr(node)
但产出
<Element obj at b743c0>
我可以怎样看待在XML档案中存在的问题? 是否有某种<条码>至_xml方法或东西?
http://lxml.de/tutorial.html#serialisation”rel=“noreferer” http://lxml.de/tutorial.html#serialisation
>>> root = etree.XML( <root><a><b/></a></root> )
>>> etree.tostring(root)
b <root><a><b/></a></root>
>>> print(etree.tostring(root, xml_declaration=True))
<?xml version= 1.0 encoding= ASCII ?>
<root><a><b/></a></root>
>>> print(etree.tostring(root, encoding= iso-8859-1 ))
<?xml version= 1.0 encoding= iso-8859-1 ?>
<root><a><b/></a></root>
>>> print(etree.tostring(root, pretty_print=True))
<root>
<a>
<b/>
</a>
</root>