iTP Active Transaction Pages (iTP ATP) Programmer's Guide
XML for ATP Add-On Module
iTP Active Transaction Pages (iTP ATP) Programmer’s Guide—522292-002
5-14
Methods
Syntax
var oNewNode = oNode.insertChild(newChild, refChild)
Parameters
newChild – The node to insert.
refChild – The reference node, which is the node before which the new node 
must be inserted.
Return Value
oReturn – The new child node being inserted.
ATPException
The following list shows the possible error-detail codes for the ATPException, 
where error code is equal to ATP_ERR_DOM_EXCEPTION.
•
HIERARCHY_REQUEST_ERR(3): Raised if this node is of a type that does 
not allow children of the type of the newChild node, or if the node to insert is 
one of this node’s ancestors.
•
WRONG_DOCUMENT_ERR(4): Raised if newChild was created from a 
different document than the one that created this node.
•
NO_MODIFICATION_ALLOWED_ERR(7): Raised if this node or the node 
being appended is read-only.
•
NOT_FOUND_ERR(8): Raised if refChild is not a child of this node.
Example
var domDoc = new XML.DOMDocument;
domDoc.load("sample.xml");
var root = domDoc.documentElement;
var node = root.childNodes.item(1);
var newNode = domDoc.createNode(1, "newNode");
node.insertBefore(newNode, node.childNodes.item(1));
println(node.xml);
Output
<student id="NUM16001">
 <newNode/><name>Jenny Mabry</name>
 <department>Computer Science</department>
 <GPA>3.6</GPA>
 <gender>Female</gender>
 <address street="Yes" permanent="Yes">1010 Fargo Drive, 
Cupertino, California 95014 </address>
 </student>
removeChild
Removes the child node indicated by oldChild from the list of children, and 
returns it.










