add new element in xml using python

shaqa

New Member
There is a list of strings such as \[code\]list=[ name, age, sex, roll, cgpa ]\[/code\]In python, how do I add these elements to XML?I have written\[code\]from xml.dom import minidomdoc = minidom.Document()testElem = doc.createElement("test")testElem.setAttribute('id', '1234')i=len(list)while i: testElem.setAttribute('testing',list) i=i-1doc.appendChild(testElem)print doc.toxml()\[/code\]When I run the above code it gives error in this line:\[code\]testElem.setAttribute('testing',list)\[/code\]How do I solve this?Thanks in advance.
 
Back
Top