Skip to content

AppendChild

Appends a new child to the specified XPath location and executes the provided callback function on the newly created node before inserting it into the DOM. Returns the appended new node.

1
myXml.AppendChild(xpath: string):Xml

Appends a new child to the specified XPath location and executes the provided callback function on the newly created node before inserting it into the DOM. Returns the appended new node.

1
myXml.AppendChild(xpath: string, callback: (node: Xml) => any):Xml

Parameters

string xpath
    XPath of the node to which the child will be appended.

(node: Xml) => any callback
    Callback function to be executed on the new node.

Returns

The newly appended Xml node. The newly appended Xml node.

Remarks

This method creates a new node and its child nodes according to the XML schema definition. An error is thrown if the XML schema definition is not found.
A qualified node path can be specified in the xpath argument when required. For example: Customer/Orders/Order.
The callback function is executed before the node is appended to the DOM tree. Monitoring events such as Xml.Bind or Xml.Live are not triggered within the callback function.
The function returns the created node after it has been appended to the DOM tree.
The callback function is invoked before the document is modified.

Appending a node:

1
2
var customer = $Xml.AppendChild('Customers/Customer');
customer.SetValue('Id','1');

This method creates a new node and its child nodes according to the XML schema definition. An error is thrown if the XML schema definition is not found.
A qualified node path can be specified in the xpath argument when required. For example: Customer/Orders/Order.
The callback function is executed before the node is appended to the DOM tree. Monitoring events such as Xml.Bind or Xml.Live are not triggered within the callback function.
The function returns the created node after it has been appended to the DOM tree.
The callback function is invoked before the document is modified.

Appending a node with a callback:

1
2
3
$Xml.AppendChild('Customers/Customer', function(newNode) {
  newNode.SetValue('Id','1');
});

See Also