XML Dom question

J

John Taylor

I am trying to insert a new element and value into a XML Dom structure
and am having some trouble.

When I read the file in from disk, I have this:

<object name='menu__File__Exit' class='wxMenuItem'>
<label>E_xit</label>
<event class='EVT_MENU'>On__File__Exit</event>
</object>

When I run this code:

w = walker.currentNode
if "menu__File__Exit" == name and 0 == needs_value and 0 == test:
myNode = doc.createElement("shortcut_key")
myNode.setAttribute("modifier","SHIFT")
w.appendChild( myNode )
test = 1

I get this result:

<object name='menu__File__Exit' class='wxMenuItem'>
<label>E_xit</label>
<event class='EVT_MENU'>On__File__Exit</event>
<shortcut_key modifier='SHIFT'/>
</object>

This is what I really want:
<shortcut_key modifier='SHIFT'/>F4</shortcut_key>

Can some one post code on how to do this? I tried creating a new Node
(called newNode) and setting the nodeType and NodeValue and the use
the appendChild() method, but I keep getting this error:

code:
myNode.appendChild(newNode)

error:
AttributeError: Node instance has no attribute 'childNodes'

Any help would be greatly appreciated!

Thanks,
-John
 

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

No members online now.

Forum statistics

Threads
474,206
Messages
2,571,069
Members
47,675
Latest member
RollandKna

Latest Threads

Top