Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 20th, 2006, 2:21 PM   #1
MegaArcon
Programmer
 
MegaArcon's Avatar
 
Join Date: Aug 2005
Posts: 66
Rep Power: 0 MegaArcon is an unknown quantity at this point
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! ^_^
MegaArcon is offline   Reply With Quote
Old Feb 20th, 2006, 2:48 PM   #2
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
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)
Arevos is offline   Reply With Quote
Old Feb 21st, 2006, 6:53 AM   #3
MegaArcon
Programmer
 
MegaArcon's Avatar
 
Join Date: Aug 2005
Posts: 66
Rep Power: 0 MegaArcon is an unknown quantity at this point
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!
MegaArcon is offline   Reply With Quote
Old Feb 21st, 2006, 7:52 AM   #4
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by MegaArcon
Thanks Arevos! Worked like a charm. Only problem is you had the parameters mixed up.
Bah, nobody's perfect
Arevos is offline   Reply With Quote
Old Feb 21st, 2006, 12:37 PM   #5
MegaArcon
Programmer
 
MegaArcon's Avatar
 
Join Date: Aug 2005
Posts: 66
Rep Power: 0 MegaArcon is an unknown quantity at this point
Hey, you helped me solve my problem. No complaints from me...constructive criticism perhaps...but no complaints.
MegaArcon is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:16 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC