我有两个xml文件: (一)模型.xml 2) 投影onParametersTemplate.xml在
我想从1)算法节点和他的孩子提取并放在2)
我写了这段代码,但它不起作用。在
from xml.dom.minidom import Document
from xml.dom import minidom
xmlmodel=minidom.parse("/home/michele/Scrivania/d/model.xml")
xmltemplate=minidom.parse("/home/michele/Scrivania/d/projectionParametersTemplate.xml")
for Node in xmlmodel.getElementsByTagName("Algorithm"):
print "\nNode: "+str(Node)
for Node2 in xmltemplate.getElementsByTagName("ProjectionParameters"):
print "\nNode2: "+str(Node2)
Node2.appendChild(Node)
这是模型.xmllink text
这是projectionParametersTemplate.xmllink text
非常感谢。在
对我来说,它是有效的,例如,xmlmodel中的算法节点被添加到xmltemplate的ProjectionParameters节点中。在
我猜你想改变实际的文件。使用您的代码,只修改内存中的对象,而不修改磁盘上的文件。如果要更改文件,请在末尾添加以下行:
注:如果你提高了录取率,也许你会得到更多的答案。在
相关问题 更多 >
编程相关推荐