我想要合并两个文件。我试图捕获特定元素,并将它们附加到另一个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的末尾。任何帮助!?