我有两个文件要合并。我试图捕获特定的元素,并将它们附加到另一个xml文件的末尾。到目前为止我得到了这个。。在
from lxml import etree
parser = etree.XMLParser(remove_blank_text=True)
filename = "/Users/eeamesX/work/data/xmltest/output.xml"
tree = etree.parse(filename, parser)
etree.tostring(tree)
root = tree.getroot()
etree.tostring(root)
allTranscripts = root.findall(".//Speaker")
allTranscripts2 = root.findall(".//Device")
for t in allTranscripts:
print etree.tostring(t)
for e in allTranscripts2:
print etree.tostring(e)
现在,我想使用这个从file1.xml获取数据,并将数据添加到file2.xml的末尾。有什么帮助吗!?在
目前没有回答
相关问题 更多 >
编程相关推荐