Inserting xml nodes in an existing xml document with python

FrozenSun

New Member
I am trying to insert xml nodes in this document: \[code\]</providers></root>\[/code\]I wrote this code: import xml.dom.minidom as m\[code\]doc = m.parse("monfichier.xml")valeurs = doc.getElementsByTagName("providers")element = doc.createElement("provider")valeurs.appendChild(element)elthost = doc.createElement("hostnamep") eltLTVC = doc.createElement("LocalTrustValueC")element.appendchild(elthost)element.appendchild(eltLTVC)texteHost = doc.createTextNode("machinename")texteLTVC = doc.createTextNode("23") eltHost.appendChild(texteHost)eltLTVC.appendChild(texteLTVC)doc.writexml(open("monfichier.xml","w"))\[/code\]And I want to obtain at the end this xml document : machinename 23\[code\] </provider> </providers></root>\[/code\]But I obtained this error : valeurs.appendChild(element) AttributeError: 'NodeList' object has no attribute 'appendChild'
 
Back
Top