Python & DOM

D

Drazen Gemic

Hi !

I need to create a XML document using DOM. How do I set the element value,
after creating it with 'createElement' ? Documentation states that there
is a 'read-only' 'nodeValue' variable. I don't know what means 'read-only
variable' in Python, but the fact is that setting that variable does not
help.

Java DOM API has 'setNodeValue' method. Is there anything corresponding in
Python DOM ?

DG
 
S

simon.dahlbacka

textNode = yourDocumentElement.createTextNode("the content")
yourElement.appendChild(textNode)

/S
 
D

Drazen Gemic

textNode = yourDocumentElement.createTextNode("the content")
yourElement.appendChild(textNode)
Thanks, it works, but 'yourDocumentElement' needs to be of type
'document'. The name leads to conclusion that it needs to be
a root element of the document.

DG
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,240
Messages
2,571,208
Members
47,845
Latest member
vojosay

Latest Threads

Top