The appendChild() method adds a child node to an existing node.
The new node is added (appended) after any existing child nodes.
Note: Use insertBefore() if the position of the node is important.
The following code fragment creates an element (), and adds it after the last child of the first element:
xmlDoc=loadXMLDoc("books.xml");
newel=xmlDoc.createElement("edition");
x=xmlDoc.getElementsByTagName("book")[0];
x.appendChild(newel);
The insertBefore() method is used to insert a node before a specified child node.
This method is useful when the position of the added node is important:
xmlDoc=loadXMLDoc("books.xml");
newNode=xmlDoc.createElement("book");
x=xmlDoc.documentElement;
y=xmlDoc.getElementsByTagName("book")[3];
x.insertBefore(newNode,y);
check this link for more details
http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/e3f3c6b1-43ee-46d7-bc09-edb8dcedb8d1[
^]