Skip to main content
Version: 2026.1

XML

Constructors​

Constructor​

new XML(message?): XML

Parameters​

message?
string

Returns​

XML

Methods​

addNamespace​

addNamespace(namespace): void

Adds the namespace to the in-scope namespaces of the element

Parameters​

namespace
string

Returns​

void

appendChild​

appendChild(child): void

Adds the given child as a new child of the element, after all other children

Parameters​

child
XML

Returns​

void

attribute​

attribute(attributeName): string

Returns the attribute with the requested name

Parameters​

attributeName
string

Returns​

string

attributes​

attributes(): string[]

Returns all attributes of this element

Returns​

string[]

child​

child(propertyName): XML[]

Returns the child element with the given propertyName, or if propertyName is an integer, returns the child in that position

Parameters​

propertyName
string | number

Returns​

XML[]

childIndex​

childIndex(): number

Returns the index of this child among its siblings

Returns​

number

children​

children(): XML[]

Returns all children of this object

Returns​

XML[]

comments​

comments(): string

Returns all the comments that are children of this XML object

Returns​

string

contains​

contains(value): boolean

Compares this element with the value, primarily provided to enable an XML element and an XML list to be used interchangeably

Parameters​

value
string

Returns​

boolean

copy​

copy(): XML

Returns a deep copy of this element (children, grandchildren, ...)

Returns​

XML

descendants​

descendants(name?): XML[]

Returns the descendant elements. If a name is provided, only elements with that name are returned.

Parameters​

name?
string

Returns​

XML[]

elements​

elements(name?): XML[]

Returns the child elements. If a name is provided, only elements with that name are returned

Parameters​

name?
string

Returns​

XML[]

hasComplexContent​

hasComplexContent(): boolean

Returns true for elements with child elements, otherwise false

Returns​

boolean

hasSimpleContent​

hasSimpleContent(): boolean

Returns true for attributes, text nodes, or elements without child elements, otherwise false

Returns​

boolean

inScopeNamespaces​

inScopeNamespaces(): string[]

Returns an array of namespaces in scope for this object

Returns​

string[]

insertChildAfter​

insertChildAfter(child1, child2): void

Inserts child2 immediately after child1 in the XML object's children list

Parameters​

child1
XML
child2
XML

Returns​

void

insertChildBefore​

insertChildBefore(child1, child2): void

Inserts child2 immediately prior to child1 in the XML object's children list

Parameters​

child1
XML
child2
XML

Returns​

void

length​

length(): number

Returns 1 for XML objects (allowing an XML object to be treated like an XML List with a single item)

Returns​

number

localName​

localName(): string

Returns the local name of this object

Returns​

string

name​

name(): string

Returns the qualified name of this object

Returns​

string

namespace​

namespace(prefix?): string

Returns the namespace associated with this object, or if a prefix is specified, an in-scope namespace with that prefix

Parameters​

prefix?
string

Returns​

string

namespaceDeclarations​

namespaceDeclarations(): string[]

An array of namespace objects representing the namespace declarations associated with this object

Returns​

string[]

nodeKind​

nodeKind(): string

A string representing the kind of object this is (e.g. "element")

Returns​

string

normalize​

normalize(): void

Merge adjacent text nodes and eliminate empty ones

Returns​

void

parent​

parent(): XML

The parent of this object

Returns​

XML

prependChild​

prependChild(value): void

Add a new child to an element, prior to all other children

Parameters​

value
XML

Returns​

void

processingInstructions​

processingInstructions(name?): string[]

A list of all processing instructions that are children of this element. If a name is provided, only processing instructions matching this name will be returned.

Parameters​

name?
string

Returns​

string[]

removeNamespace​

removeNamespace(value): void

Removes a namespace from the in-scope namespaces of the element

Parameters​

value
string

Returns​

void

replace​

replace(propertyName, value): any

Replace a child with a new value

Parameters​

propertyName
string
value
XML

Returns​

any

setChildren​

setChildren(value): void

Replace all children of this object with the given ones

Parameters​

value
XML[]

Returns​

void

setLocalName​

setLocalName(name): void

Sets the local name of this XML object to the requested value

Parameters​

name
string

Returns​

void

setName​

setName(name): void

Sets the name of this XML object to the requested value

Parameters​

name
string

Returns​

void

setNamespace​

setNamespace(ns): void

Sets the namespace of this XML object to the requested value

Parameters​

ns
string

Returns​

void

text​

text(): string

Concatenation of all text node children

Returns​

string

toString​

toString(): string

For elements without element children, returns the values of the text node children. For elements with children, returns same as toXMLString. For other kinds of objects, the value of the object.

Returns​

string

toXMLString​

toXMLString(): string

Serializes this XML object as parse-able XML

Returns​

string

valueOf​

valueOf(): XML

Returns this XML object

Returns​

XML

Indexable​

[key: string]: any