Node.appendChild(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Appends a node after the last child node of a specific element node. Returns the new child node.

Returns

xml.Node

Supported Script Types

Client and server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/xml Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.newChild

xml.Node

required

xml.Node object to append.

Errors

Error Code

Message

Thrown If

SSS_XML_DOM_EXCEPTION

HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.

Node cannot be appended.

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/xml Module Script Samples.

          //Add additional code 
...
var bookShelf = xml.Parser.fromString(file.load('SuiteScripts/books.xml').getContents()); 

var newBookNode = xmlData.createElement("book"); 
var newTitleNode = xmlData.createElement("title"); 
var newTitleNodeValue = xmlData.createTextNode(""); 
var newAuthorNode = xmlData.createElement("author"); 
var newAuthorNodeValue = xmlData.createTextNode("");
newTitleNode.appendChild(newTitleNodeValue);
newAuthorNode.appendChild(newAuthorNodeValue);
newBookNode.appendChild(newTitleNode);
newBookNode.appendChild(newAuthorNode);

var newbook = bookShelf.appendChild({
   newChild : newBookNode
});
...
//Add additional code 

        

Related Topics

xml.Node
N/xml Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices