Node.replaceChild(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Replaces a specific child node with another child node in a list of child nodes.

If the new child node to add already exists in the list of child nodes, the node is first removed.

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

New child node to add.

options.oldChild

xml.Node

required

Child node to replaced with the new node.

Errors

Error Code

Message

Thrown If

SSS_XML_DOM_EXCEPTION

NOT_FOUND_ERR: An attempt is made to reference a node in a context where it does not exist.

Child node cannot be found.

SSS_XML_DOM_EXCEPTION

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

Child node cannot be replaced.

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 replacednode = parentNode.replaceChild({
    newChild : elem[2],
    oldChild : elem[1]
});
...
//Add additional code 

        

Related Topics

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

General Notices