N/xml Module
Use the N/xml module to validate, parse, read, and modify XML documents.
In This Help Topic
N/xml Module Members
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Object |
Object |
Client and server scripts |
Represents an attribute node of an xml.Element object. |
|
Object |
Client and server scripts |
Represents an entire XML document. The XML DOM presents a document as a hierarchy of node objects. Use the methods and properties available to the xml.Document object to manipulate the XML document and the nodes in the document tree. |
||
Object |
Client and server scripts |
Represents an element in an XML document. Elements may contain attributes, other elements, or text. If an element contains text, the text is represented in a text node of type TEXT_NODE. |
||
Object |
Client and server scripts |
Represents a generic XML node in an XML document. A node can be a Document, Element, or Attribute. |
||
Object |
Client and server scripts |
Encapsulates the functionality used by NetSuite to parse XML. |
||
Object |
Client and server scripts |
Encapsulates the functionality used by NetSuite to run XPath expressions. XPath is a standard for enumerating paths in an XML document collection. |
||
Method |
string |
Client and server scripts |
Prepares a string for use in XML by escaping XML markup, such as angle brackets, quotation marks, and ampersands. |
|
void |
Server scripts |
Validates an XML document against an XML Schema (XSD). |
||
Enum |
string (read-only) |
Client and server scripts |
Holds the string values for the supported node types. Use this enum to set the Node.nodeType property. |
Attr Object Members
The following members are called on the xml.Attr object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Property |
xml.Element (read-only) |
Client and server scripts |
The xml.Element object that is the parent of the xml.Attr object. |
|
string (read-only) |
Client and server scripts |
The name of an attribute. |
||
boolean |
Client and server scripts |
Returns |
||
string |
Client and server scripts |
Value of an attribute. The value of the attribute is returned as a string. Character and general entity references are replaced with their values. |
Document Object Members
In addition to the Document object members, Document objects inherit the members of the Node object. The methods and properties associated with a Node object can be used as members of a Document object. For more information, see Node Object Members.
The following members are called on the xml.Document object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
Client and server scripts |
Attempts to adopt a node from another document to this document. |
||
Client and server scripts |
Creates an attribute node of type ATTRIBUTE_NODE with the optional specified value. |
|||
Client and server scripts |
Creates an attribute node of type ATTRIBUTE_NODE, with the specified namespace value and optional specified value. |
|||
Client and server scripts |
Creates a CDATA section node of type DOCUMENT_FRAGMENT_NODE with the specified data. |
|||
Client and server scripts |
Creates a Comment node of type COMMENT_NODE with the specified string. |
|||
Client and server scripts |
Creates a node of type DOCUMENT_FRAGMENT_NODE. |
|||
Client and server scripts |
Creates a new node of type ELEMENT_NODE with the specified name. |
|||
Client and server scripts |
Creates a new node of type ELEMENT_NODE with the specified namespace URI and name. |
|||
Client and server scripts |
Creates a new node of type PROCESSING_ |
|||
Client and server scripts |
Creates a new node of type TEXT_NODE. |
|||
Client and server scripts |
Returns the element that has an ID attribute with the specified value as an xml.Element object. |
|||
Client and server scripts |
Returns an array of xml.Element objects with a specific tag name, in the order in which they appear in the XML document. |
|||
Client and server scripts |
Returns an array of xml.Element objects with a specific tag name and namespace, in the order in which they appear in the XML document. |
|||
Client and server scripts |
Imports a node from another document to this document. Creates a new copy of the source node. |
|||
Property |
Object (read-only) |
Client and server scripts |
Returns a node of type DOCUMENT_TYPE_NODE that represents the doctype of the XML document. |
|
xml.Element (read-only) |
Client and server scripts |
Root node of the XML document. |
||
string (read-only) |
Client and server scripts |
Location of the document or |
||
string (read-only) |
Client and server scripts |
Encoding used for an XML document at the time the document was parsed. |
||
string (read-only) |
Client and server scripts |
Part of the XML declaration, the XML encoding of the XML document. |
||
boolean |
Client and server scripts |
Part of the XML declaration, returns |
||
string |
Client and server scripts |
Part of the XML declaration, the version number of the XML document. |
Element Object Members
In addition to the Element object members, Element objects inherit the members of the Node object. The methods and properties associated with a Node object can be used as members of a Element object. For more information, see Node Object Members.
The following members are called on the xml.Element object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
string |
Client and server scripts |
Returns the value of the specified attribute. |
|
Client and server scripts |
Retrieves an attribute node by name. |
|||
string |
Client and server scripts |
Returns an attribute node with the specified namespace URI and local name. |
||
Client and server scripts |
Returns an attribute value with the specified namespace URI and local name. |
|||
Client and server scripts |
Returns an array of descendant xml.Element objects with a specific tag name, in the order in which they appear in the XML document. |
|||
Client and server scripts |
Returns an array of descendant xml.Element objects with a specific tag name and namespace, in the order in which they appear in the XML document. |
|||
boolean |
Client and server scripts |
Returns |
||
boolean |
Client and server scripts |
Returns |
||
void |
Client and server scripts |
Removes the attribute with the specified name. |
||
Client and server scripts |
Removes the attribute specified as a xml.Attr object. |
|||
void |
Client and server scripts |
Removes the attribute with the specified namespace URI and local name. |
||
void |
Client and server scripts |
Adds a new attribute with the specified name. If an attribute with that name is already present in the element, its value is changed to the value specified in method argument. |
||
Client and server scripts |
Adds the specified attribute node. If an attribute with the same name is already present in the element, it is replaced by the new one. |
|||
Client and server scripts |
Adds the specified attribute node. If an attribute with the same local name and namespace URI is already present in the element, it is replaced by the new one. |
|||
void |
Client and server scripts |
Adds a new attribute with the specified name and namespace URI. If an attribute with the same name and namespace URI is already present in the element, its value is changed to the value specified in method argument. |
||
Property |
string (read-only) |
Client and server scripts |
The tag name of this xml.Element object. |
Node Object Members
The following members are called on the xml.Node object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
Client and server scripts |
Appends a node after the last child node of a specific element node. Returns the new child node. |
||
Client and server scripts |
Creates a copy of a node. Returns the copied node. |
|||
number |
Client and server scripts |
Returns a number that reflects where two nodes are located, compared to each other. |
||
boolean |
Client and server scripts |
Returns |
||
boolean |
Client and server scripts |
Returns |
||
Client and server scripts |
Inserts a new child node before an existing child node for the current node. |
|||
boolean |
Client and server scripts |
Returns |
||
boolean |
Client and server scripts |
Returns |
||
boolean |
Client and server scripts |
Returns |
||
string |
Client and server scripts |
Returns the namespace uniform resource identifier (URI) that matches the specified namespace prefix. |
||
string |
Client and server scripts |
Returns the namespace prefix associated with the specified namespace uniform resource identifier (URI). |
||
void |
Client and server scripts |
Puts all text nodes underneath a node, including attribute nodes, into a normal form. |
||
Client and server scripts |
Removes the specified child node. Returns the removed child node. |
|||
Client and server scripts |
Replaces a specific child node with another child node in a list of child nodes. |
|||
Property |
Object (read-only) |
Client and server scripts |
Key-value pairs for all attributes for an xml.Element node. Returns |
|
string (read-only) |
Client and server scripts |
Absolute base uniform resource identifier (URI) of a node or |
||
xml.Node[] (read-only) |
Client and server scripts |
Array of all child nodes of a node or an empty array if there are no child nodes. |
||
xml.Node (read-only) |
Client and server scripts |
First child node for a specific node or |
||
xml.Node (read-only) |
Client and server scripts |
Last child node for a specific node or |
||
string (read-only) |
Client and server scripts |
The local part of the qualified name of a node. |
||
string (read-only) |
Client and server scripts |
The namespace uniform resource identifier (URI) of a node or |
||
xml.Node (read-only) |
Client and server scripts |
The next node in a node list or |
||
string (read-only) |
Client and server scripts |
Name of a node, depending on the type. For example, for a node of type xml.Element, the name is the name of the element. |
||
string |
Client and server scripts |
The type of node defined as a value from the xml.NodeType enum. |
||
string |
Client and server scripts |
The value of a node, depending on its type. |
||
xml.Document (read-only) |
Client and server scripts |
The root element for a node as a xml.Document object. |
||
xml.Node (read-only) |
Client and server scripts |
The parent node of a node. |
||
string |
Client and server scripts |
The namespace prefix of the node, or |
||
xml.Node (read-only) |
Client and server scripts |
The previous node in a node list or |
||
string |
Client and server scripts |
The textual content of a node and its descendants. |
Parser Object Members
The following members are called on the xml.Parser object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
Client and server scripts |
Parses a string into a W3C XML document object. |
||
string |
Client and server scripts |
Converts (serializes) an xml.Document object into a string. |
XPath Object Members
The following members are called on the xml.XPath object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
xml.Node[] |
Client and server scripts |
Selects an array of nodes from an XML document using an XPath expression. |