- ATTRIBUTE_NODE
- CDATA_SECTION_NODE
- COMMENT_NODE
- DOCUMENT_FRAGMENT_NODE
- DOCUMENT_NODE
- DOCUMENT_TYPE_NODE
- ELEMENT_NODE
- ENTITY_NODE
- ENTITY_REFERENCE_NODE
- NOTATION_NODE
- PROCESSING_INSTRUCTION_NODE
- TEXT_NODE
A class describing an CDataNode.
new CDataNode(value?: string): CDataNode;Constructs a new CDataNode instance.
| Parameter | Type | Default value | Description |
|---|---|---|---|
value? |
string |
'' |
The data for the node |
CDataNode
| Property | Type | Default value | Description | Inherited from |
|---|---|---|---|---|
childNodes |
Node[] |
[] |
The node's immediate children. | Node.childNodes |
nodeName |
string |
'#node' |
A node type string identifier. | Node.nodeName |
nodeType |
number |
0 |
A numerical node type identifier. | Node.nodeType |
parentNode |
Node | null |
null |
The node's parent node. | Node.parentNode |
value |
string |
undefined |
The nodes data value. | - |
get preserveSpace(): boolean;True if xml:space has been set to true for this node or any of its ancestors.
boolean
get textContent(): string;The text content of this node (and its children).
string
appendChild(node: Node): Node;Appends a child node into the current one.
| Parameter | Type | Description |
|---|---|---|
node |
Node |
The new child node |
The same node that was passed in.
toString(): string;Returns a string representation of the node.
string
A formatted XML source.
This class describes an XML document.
new Document(): Document;Constructs a new Document instance.
Document
| Property | Type | Default value | Description | Inherited from |
|---|---|---|---|---|
childNodes |
Node[] |
[] |
The node's immediate children. | Node.childNodes |
nodeName |
string |
'#node' |
A node type string identifier. | Node.nodeName |
nodeType |
number |
0 |
A numerical node type identifier. | Node.nodeType |
parentNode |
Node | null |
null |
The node's parent node. | Node.parentNode |
root |
Element | null |
null |
- | - |
get children(): Element[];A list containing all child Elements of the current Element.
Element[]
get preserveSpace(): boolean;True if xml:space has been set to true for this node or any of its ancestors.
boolean
get textContent(): string;The text content of this node (and its children).
string
appendChild(node: Element): Element;Appends a child node into the current one.
| Parameter | Type | Description |
|---|---|---|
node |
Element |
The new child node |
The same node that was passed in.
getElementsByTagName(tagName: string): Element[];Return all descendant elements that have the specified tag name.
| Parameter | Type | Description |
|---|---|---|
tagName |
string |
The tag name to filter by. |
Element[]
The elements by tag name.
querySelector(selector: string): Element | null;Return the first descendant element that match a specified CSS selector.
| Parameter | Type | Description |
|---|---|---|
selector |
string |
The CSS selector to filter by. |
Element | null
The elements by tag name.
querySelectorAll(selector: string): Element[];Return all descendant elements that match a specified CSS selector.
| Parameter | Type | Description |
|---|---|---|
selector |
string |
The CSS selector to filter by. |
Element[]
The elements by tag name.
toJS(): [] | JsonMLElement;Returns a simple object representation of the node and its descendants.
[] | JsonMLElement
JsonML representation of the nodes and its subtree.
toString(): string;Returns a string representation of the node.
string
A formatted XML source.
A class describing an Element.
new Element(
tagName: string,
attr?: Record<string, string>,
closed?: boolean): Element;Constructs a new Element instance.
| Parameter | Type | Default value | Description |
|---|---|---|---|
tagName |
string |
undefined |
The tag name of the node. |
attr? |
Record<string, string> |
{} |
A collection of attributes to assign. |
closed? |
boolean |
false |
Was the element "self-closed" when read. |
Element
| Property | Type | Default value | Description | Overrides | Inherited from |
|---|---|---|---|---|---|
attr |
Record<string, string> |
undefined |
An object of attributes assigned to this element. | - | - |
childNodes |
Node[] |
[] |
The node's immediate children. | - | Node.childNodes |
closed |
boolean |
undefined |
A state representing if the element was "self-closed" when read. | - | - |
fullName |
string |
undefined |
The full name of the tag for the given element, including a namespace prefix. | - | - |
nodeName |
string |
'#node' |
A node type string identifier. | - | Node.nodeName |
nodeType |
number |
0 |
A numerical node type identifier. | - | Node.nodeType |
ns |
string |
undefined |
The namespace prefix of the element, or null if no prefix is specified. | - | - |
parentNode |
Element | null |
null |
The node's parent node. | Node.parentNode |
- |
tagName |
string |
undefined |
The name of the tag for the given element, excluding any namespace prefix. | - | - |
get children(): Element[];A list containing all child Elements of the current Element.
Element[]
get preserveSpace(): boolean;True if xml:space has been set to true for this node or any of its ancestors.
boolean
get textContent(): string;The text content of this node (and its children).
string
appendChild(node: Node): Node;Appends a child node into the current one.
| Parameter | Type | Description |
|---|---|---|
node |
Node |
The new child node |
The same node that was passed in.
getAttribute(name: string): string | null;Read an attribute from the element.
| Parameter | Type | Description |
|---|---|---|
name |
string |
The attribute name to read. |
string | null
The attribute.
getElementsByTagName(tagName: string): Element[];Return all descendant elements that have the specified tag name.
| Parameter | Type | Description |
|---|---|---|
tagName |
string |
The tag name to filter by. |
Element[]
The elements by tag name.
hasAttribute(name: string): boolean;Test if an attribute exists on the element.
| Parameter | Type | Description |
|---|---|---|
name |
string |
The attribute name to test for. |
boolean
True if the attribute is present.
querySelector(selector: string): Element | null;Return the first descendant element that match a specified CSS selector.
| Parameter | Type | Description |
|---|---|---|
selector |
string |
The CSS selector to filter by. |
Element | null
The elements by tag name.
querySelectorAll(selector: string): Element[];Return all descendant elements that match a specified CSS selector.
| Parameter | Type | Description |
|---|---|---|
selector |
string |
The CSS selector to filter by. |
Element[]
The elements by tag name.
removeAttribute(name: string): void;Remove an attribute off the element.
| Parameter | Type | Description |
|---|---|---|
name |
string |
The attribute name to remove. |
void
setAttribute(name: string, value: string): void;Sets an attribute on the element.
| Parameter | Type | Description |
|---|---|---|
name |
string |
The attribute name to read. |
value |
string |
The value to set |
void
toJS(): JsonMLElement;Returns a simple object representation of the node and its descendants.
JsonML representation of the nodes and its subtree.
toString(): string;Returns a string representation of the node.
string
A formatted XML source.
A class describing a Node.
new Node(): Node;Node
get preserveSpace(): boolean;True if xml:space has been set to true for this node or any of its ancestors.
boolean
get textContent(): string;The text content of this node (and its children).
string
appendChild(node: Node): Node;Appends a child node into the current one.
| Parameter | Type | Description |
|---|---|---|
node |
Node |
The new child node |
Node
The same node that was passed in.
toString(): string;Returns a string representation of the node.
string
A formatted XML source.
A class describing a TextNode.
new TextNode(value?: string): TextNode;Constructs a new TextNode instance.
| Parameter | Type | Description |
|---|---|---|
value? |
string |
The data for the node |
TextNode
| Property | Type | Default value | Description | Inherited from |
|---|---|---|---|---|
childNodes |
Node[] |
[] |
The node's immediate children. | Node.childNodes |
nodeName |
string |
'#node' |
A node type string identifier. | Node.nodeName |
nodeType |
number |
0 |
A numerical node type identifier. | Node.nodeType |
parentNode |
Node | null |
null |
The node's parent node. | Node.parentNode |
value |
string |
undefined |
The node's data value. | - |
get preserveSpace(): boolean;True if xml:space has been set to true for this node or any of its ancestors.
boolean
get textContent(): string;The text content of this node (and its children).
string
appendChild(node: Node): Node;Appends a child node into the current one.
| Parameter | Type | Description |
|---|---|---|
node |
Node |
The new child node |
The same node that was passed in.
toString(): string;Returns a string representation of the node.
string
A formatted XML source.
function parseXML(source: string, options?: {
emptyDoc?: boolean;
laxAttr?: boolean;
}): Document;Parse an XML source and return a Node tree.
| Parameter | Type | Default value | Description |
|---|---|---|---|
source |
string |
undefined |
The XML source to parse. |
options? |
{ emptyDoc?: boolean; laxAttr?: boolean; } |
DEFAULTOPTIONS |
Parsing options. |
options.emptyDoc? |
boolean |
undefined |
Permit "rootless" documents. |
options.laxAttr? |
boolean |
undefined |
Permit unquoted attributes (<node foo=bar />). |
A DOM representing the XML node tree.
type JsonMLAttr = Record<string, string | number | boolean | null>;type JsonMLElement =
| [string, JsonMLAttr, ...JsonMLElement[]]
| [string, JsonMLAttr]
| [string, ...JsonMLElement[]]
| [string]
| string;const ATTRIBUTE_NODE: number = 2;An attribute node identifier
const CDATA_SECTION_NODE: number = 4;A CData Section node identifier
const COMMENT_NODE: number = 8;A comment node identifier
const DOCUMENT_FRAGMENT_NODE: number = 11;A document fragment node identifier
const DOCUMENT_NODE: number = 9;A document node identifier
const DOCUMENT_TYPE_NODE: number = 10;A document type node identifier
const ELEMENT_NODE: number = 1;An element node identifier
const ENTITY_NODE: number = 6;An entity node identifier
const ENTITY_REFERENCE_NODE: number = 5;An entity reference node identifier
const NOTATION_NODE: number = 12;A documentation node identifier
const PROCESSING_INSTRUCTION_NODE: number = 7;A processing instruction node identifier
const TEXT_NODE: number = 3;A text node identifier