# Titanium.XML.Node
A single node in the Titanium.XML.Document tree.
# Overview
Implements the DOM Level 2 API (opens new window) on Android and iOS.
Note that on iOS, only Titanium.XML.Element nodes are mutable. This means
that the methods appendChild
, insertBefore
, removeChild
, and
replaceChild
only work on Element
objects. If one of these methods is called on
another type of node, it throws an exception.
# Properties
# attributes READONLY
A map of this node's attributes.
As defined by the DOM specification, only Titanium.XML.Element nodes have attributes.
For all other node types, this property is always null
.
# childNodes READONLY
A Titanium.XML.NodeList of this node's children.
# localName
Local part of the qualified name of this node.
The local part of the qualified name that comes after the colon. That is, the name without the namespace prefix.
# nodeName READONLY
Name of this node.
Certain node types have constant values defined by the DOM specification:
- Text node:
#text
- Comment node:
#comment
- CDATA section node:
#cdata-section
- Document node:
#document
- Document fragment node:
#document-fragment
# nodeType READONLY
This node's type. One of ELEMENT_NODE
, ATTRIBUTE_NODE
, TEXT_NODE
, CDATA_SECTION_NODE
,
ENTITY_REFERENCE_NODE
, ENTITY_NODE
, PROCESSING_INSTRUCTION_NODE
, COMMENT_NODE
,
DOCUMENT_NODE
, DOCUMENT_TYPE_NODE
, DOCUMENT_FRAGMENT_NODE
, NOTATION_NODE
.
# nodeValue
Content (value) of this node.
As defined in the DOM specification, the node value is always null
for
Document, DocumentFragment, DocumentType, Element, Entity, EntityReference, and
Notation nodes.
# ownerDocument READONLY
This node's owning document.
Note that a node always has an owning document, even if it is not part of the document tree.
For more on node ownership, see ownerDocument issues in the W3C DOM FAQ.
# prefix
Namespace prefix of this node.
Read-only on iOS, read-write on other platforms.
# text READONLYDEPRECATED
DEPRECATED SINCE 2.0.0
Use textContent instead.
Content (value) of all text nodes within this node.
# textContent READONLY
Content (value) of all text nodes within this node.
On Android, textContent
is supported on Titanium.XML.Element and
Titanium.XML.Text nodes only.
# Methods
# appendChild
Appends the node newChild
as a child of this node.
On iOS, appendChild
is supported on Titanium.XML.Element
nodes only.
Parameters
Name | Type | Description |
---|---|---|
newChild | Titanium.XML.Node | New node to append. |
Returns
Newly-appended node.
- Type
- Titanium.XML.Node
# cloneNode
Returns a duplicate of this node.
Parameters
Name | Type | Description |
---|---|---|
deep | Boolean | Whether or not to perform a deep copy of this node. |
Returns
Cloned node.
- Type
- Titanium.XML.Node
# hasAttributes
Returns true
if this node has attributes.
Returns
True if this node has attributes, false if it does not.
- Type
- Boolean
# hasChildNodes
Returns true
if this node has child nodes.
Returns
True if this node has children, false if it does not.
- Type
- Boolean
# insertBefore
Inserts the node newChild
before the node refChild
.
On iOS, insertBefore
is supported on Titanium.XML.Element
nodes only.
Parameters
Name | Type | Description |
---|---|---|
newChild | Titanium.XML.Node | Node to insert. |
refChild | Titanium.XML.Node | Node to insert |
Returns
The inserted node.
- Type
- Titanium.XML.Node
# isSupported
Tests whether the DOM implementation supports a specific feature.
Parameters
Name | Type | Description |
---|---|---|
feature | String | Name of the feature. |
version | String | Version number of the feature. |
Returns
True if the feature is supported, false if it is not.
- Type
- Boolean
# normalize
Normalizes text and attribute nodes in this node's child hierarchy.
Returns
- Type
- void
# removeChild
Removes a child node from this node.
On iOS, removeChild
is supported on Titanium.XML.Element
nodes only.
Parameters
Name | Type | Description |
---|---|---|
oldChild | Titanium.XML.Node | Node to remove. |
Returns
Node that was removed.
- Type
- Titanium.XML.Node
# replaceChild
Replaces the node oldChild
with the node newChild
.
On iOS, replaceChild
is supported on Titanium.XML.Element
nodes only.
Parameters
Name | Type | Description |
---|---|---|
newChild | Titanium.XML.Node | New node. |
oldChild | Titanium.XML.Node | Node being replaced. |
Returns
Node that was replaced.
- Type
- Titanium.XML.Node
# Constants
# CDATA_SECTION_NODE
Used with nodeType to identify a Titanium.XML.CDATASection node.
# DOCUMENT_FRAGMENT_NODE
Used with nodeType to identify a Titanium.XML.DocumentFragment node.
# DOCUMENT_TYPE_NODE
Used with nodeType to identify a Titanium.XML.DocumentType node.
# ENTITY_REFERENCE_NODE
Used with nodeType to identify an Titanium.XML.EntityReference node.
# PROCESSING_INSTRUCTION_NODE
Used with nodeType to identify a Titanium.XML.ProcessingInstruction node.