Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
请想象变量中的 XML 节点n。
n
如果我通过 MSXML 访问这个节点,我可以通过.xml属性获取节点的 XML 源,即n.xml返回整个节点源。
.xml
n.xml
我怎样才能对 lxml 做同样的事情?
使用.tostring()方法:
.tostring()
from lxml import etree print etree.tostring(node)