Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting XML element into string and again string to XML file in python

How would I convert an XML element into string and a string back to XML format using xml.elementtree in web2py ?

like image 972
NoviceInPython Avatar asked Apr 08 '26 07:04

NoviceInPython


1 Answers

Use parseString to get xml element from string and toxml to make string out of xml element. Something like this.

from xml.dom.minidom import parseString

dom = minidom.parseString(content)
...
# do some changes to dom here
return dom.toxml()
like image 157
Devi Avatar answered Apr 10 '26 21:04

Devi