我正在迭代xml节点值,这是我从xpath查询得到的。我需要为某个节点值分配一个引用。
这就是我想要的:
from lxml import etree
doc = etree.fromstring(some_xml)
nodes = doc.xpath('some_query')
for node in nodes:
if node.text == 'smth':
#there i need to assign reference
reference = node.text
#after iterating i need to that change the node value
reference = 'hello world'
有没有办法在python中做到这一点?
谢谢!
答案 0 :(得分:1)