add element with attributes in minidom python
I want to add a child node with attributes to a specific tag. my xml is <deploy> </deploy> and the output should be <deploy> <script name="xyz" action="stop"/> </deploy> so far my code is: dom = parse("deploy.xml") script = dom.createElement("script") dom.childNodes[0].appendChild(script) dom.writexml(open(weblogicDeployXML, 'w')) script.setAttribute("name", args.script) How can I figure out how to find deploy tag and append child node with attributes ? William A. Romero R. xml.dom.Element.setAttribute xmlFile = minidom.parse( FILE_PATH ) for script in SCRIPTS: newScript = xmlFile