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