![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Aug 2005
Posts: 66
Rep Power: 0
![]() |
Adding nodes with minidom
Hi all! ^_^
I'm working on some xml stuff with python and I'm having a bit of trouble. I'm taking in an xml document and trying to add an xml element to the existing document in a paticuar place. The only method I'm aware python has to add nodes is the "appendChild" method. However, I'm looking for a method like javascripts "insertAfter" method which will append the node after the given node. Any ideas? Thanks! ^_^ |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
It seems to me that inserting a node directly after node 'x', is the same as inserting a node before the next sibling of 'x'.
node.insertBefore(x.nextSibling, new_node) |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Aug 2005
Posts: 66
Rep Power: 0
![]() |
Thanks Arevos! Worked like a charm. Only problem is you had the parameters mixed up.
rootNode.insertBefore(new_node, node_to_insert_before) Appreciate the help! ![]() |
|
|
|
|
|
#4 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
![]() |
|
|
|
|
|
|
#5 |
|
Programmer
Join Date: Aug 2005
Posts: 66
Rep Power: 0
![]() |
Hey, you helped me solve my problem. No complaints from me...constructive criticism perhaps...but no complaints.
![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|