Inserting nodes into an existing XML document in GWT client using XMLParser

wayneapricot

New Member
I have an xml document (using the Document class in the XMLParser library of GWT client) with a format like follows:\[code\]<document><node id="0">content</node><node id="1">more content</node></document>\[/code\]Given an ID, I need to insert a new node immediately after the node with that ID.So far I've tried using insertBefore (as there is no insertAfter), but I must be using it incorrectly as nothing happens (apart from an UmbrellaException in the js console). I can't find any example usage via search engines.My attempt is as follows (where n is the node I want to insert after):\[code\]Node nNext = n.getNextSibling(); //To get the next sibling to use it with insertBeforeElement newNode = doc.createElement("node");newNode.appendChild(doc.createTextNode("new content")); //seems to work up until heren.insertBefore(newNode, nNext); //so this line could be the problem?\[/code\]I'm sure it's something obvious, but this is driving me crazy, so any help would be greatly appreciated.
 
Back
Top