470,647 Members | 1,195 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,647 developers. It's quick & easy.

Python & DOM

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

Jul 19 '05 #1
2 1604
textNode = yourDocumentElement.createTextNode("the content")
yourElement.appendChild(textNode)

/S

Jul 19 '05 #2
On Mon, 23 May 2005 22:37:09 -0700, si*************@gmail.com wrote:
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
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by james blair | last post: by
2 posts views Thread by . | last post: by
3 posts views Thread by John Nagle | last post: by
8 posts views Thread by js | last post: by
reply views Thread by OldManRiver | last post: by
4 posts views Thread by Jive Dadson | last post: by
3 posts views Thread by bsagert | last post: by
reply views Thread by warner | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.