我可以插入这样的元素:
product_node.insert(cnt, etree.Element("vod_type"))
是否可以执行以下操作:
product_node.insert(cnt, etree.Element("vod_type").text="hello")
或者类似的东西。或者我必须把它分成三行吗?
elem = etree.Element("vod_type")
elem.text = "hello"
product_node.insert(cnt, elem)
ElementMaker 可用于一步完成此操作
from lxml.builder import E
product_node.insert(cnt, E("vod_type", "hello"))