Answer the question
In order to leave comments, you need to log in
How to insert a text value into an XML node using Python and xml.dom.minidom?
Hello.
I use xml.dom.minidom.
An xml element of the following type is selected:
>>> element = xml.getElementsByTagName('Description')[0]
>>> element
<DOM Element: Description at 0x2ed6468>
>>> element.toxml()
u'<Description/>'
u'<Description>value</Description>'
>>> element.setAttribute('value','newAttr')
>>> element.toxml()
u'<Description value="newAttr"/>'
Answer the question
In order to leave comments, you need to log in
Strictly speaking, "just text" inside an element is a nested element, like a text node, this is how it should work:element.appendChild(xml.createTextNode('value!'))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question