# Titanium.XML.Node

> A single node in the [Document](https://titaniumsdk.com/docs/sdk/Titanium.XML.Document.md) tree.

- Source: https://titaniumsdk.com/docs/sdk/12.7.1/Titanium.XML.Node
- Titanium SDK version: 12.7.1
- Kind: proxy
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK Android 0.9, iPhone 0.9, iPad 0.9, macOS 9.2.0
- Extends: Titanium.Proxy
- Inheritance: Titanium.Proxy

Implements the [DOM Level 2 API](https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247)
on Android and iOS.

Note that on iOS, only [Element](https://titaniumsdk.com/docs/sdk/Titanium.XML.Element.md) 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

### ATTRIBUTE_NODE

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only
- Value: `2`

Used with [nodeType](https://titaniumsdk.com/docs/sdk/Titanium.XML.Node.md#nodeType) to identify an
[Attr](https://titaniumsdk.com/docs/sdk/Titanium.XML.Attr.md) node.

### attributes

- Type: Titanium.XML.NamedNodeMap
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

A map of this node's attributes.

As defined by the DOM specification, only [Element](https://titaniumsdk.com/docs/sdk/Titanium.XML.Element.md) nodes have attributes.
For all other node types, this property is always `null`.

### CDATA_SECTION_NODE

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only
- Value: `4`

Used with [nodeType](https://titaniumsdk.com/docs/sdk/Titanium.XML.Node.md#nodeType) to identify a
[CDATASection](https://titaniumsdk.com/docs/sdk/Titanium.XML.CDATASection.md) node.

### childNodes

- Type: Titanium.XML.NodeList
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

A [Titanium.XML.NodeList](https://titaniumsdk.com/docs/sdk/Titanium.XML.NodeList.md) of this node's children.

### COMMENT_NODE

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only
- Value: `8`

Used with [nodeType](https://titaniumsdk.com/docs/sdk/Titanium.XML.Node.md#nodeType) to identify a
[Comment](https://titaniumsdk.com/docs/sdk/Titanium.XML.Comment.md) node.

### DOCUMENT_FRAGMENT_NODE

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only
- Value: `11`

Used with [nodeType](https://titaniumsdk.com/docs/sdk/Titanium.XML.Node.md#nodeType) to identify a
[DocumentFragment](https://titaniumsdk.com/docs/sdk/Titanium.XML.DocumentFragment.md) node.

### DOCUMENT_NODE

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only
- Value: `9`

Used with [nodeType](https://titaniumsdk.com/docs/sdk/Titanium.XML.Node.md#nodeType) to identify a
[Document](https://titaniumsdk.com/docs/sdk/Titanium.XML.Document.md) node.

### DOCUMENT_TYPE_NODE

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only
- Value: `10`

Used with [nodeType](https://titaniumsdk.com/docs/sdk/Titanium.XML.Node.md#nodeType) to identify a
[DocumentType](https://titaniumsdk.com/docs/sdk/Titanium.XML.DocumentType.md) node.

### ELEMENT_NODE

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only
- Value: `1`

Used with [nodeType](https://titaniumsdk.com/docs/sdk/Titanium.XML.Node.md#nodeType) to identify an
[Element](https://titaniumsdk.com/docs/sdk/Titanium.XML.Element.md) node.

### ENTITY_NODE

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only
- Value: `6`

Used with [nodeType](https://titaniumsdk.com/docs/sdk/Titanium.XML.Node.md#nodeType) to identify an
[Entity](https://titaniumsdk.com/docs/sdk/Titanium.XML.Entity.md) node.

### ENTITY_REFERENCE_NODE

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only
- Value: `5`

Used with [nodeType](https://titaniumsdk.com/docs/sdk/Titanium.XML.Node.md#nodeType) to identify an
[EntityReference](https://titaniumsdk.com/docs/sdk/Titanium.XML.EntityReference.md) node.

### firstChild

- Type: Titanium.XML.Node
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

This node's first child.

### lastChild

- Type: Titanium.XML.Node
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

This node's last child.

### localName

- Type: String
- Platforms: Android, iPhone, iPad, macOS

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.

### namespaceURI

- Type: String
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Namespace URI of this node.

### nextSibling

- Type: Titanium.XML.Node
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

This node's next sibling.

### nodeName

- Type: String
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

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

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

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

- Type: String
- Platforms: Android, iPhone, iPad, macOS

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.

### NOTATION_NODE

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only
- Value: `12`

Used with [nodeType](https://titaniumsdk.com/docs/sdk/Titanium.XML.Node.md#nodeType) to identify a
[Notation](https://titaniumsdk.com/docs/sdk/Titanium.XML.Notation.md) node.

### ownerDocument

- Type: Titanium.XML.Document
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

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](https://www.w3.org/DOM/faq.html#ownerdoc)
in the W3C DOM FAQ.

### parentNode

- Type: Titanium.XML.Node
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

This node's parent node.

### prefix

- Type: String
- Platforms: Android, iPhone, iPad, macOS

Namespace prefix of this node.

Read-only on iOS, read-write on other platforms.

### previousSibling

- Type: Titanium.XML.Node
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

This node's previous sibling.

### PROCESSING_INSTRUCTION_NODE

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only
- Value: `7`

Used with [nodeType](https://titaniumsdk.com/docs/sdk/Titanium.XML.Node.md#nodeType) to identify a
[ProcessingInstruction](https://titaniumsdk.com/docs/sdk/Titanium.XML.ProcessingInstruction.md) node.

### text

- Type: String
- Platforms: iPhone, iPad, macOS
- Permission: read-only
- DEPRECATED since 2.0.0. Use [Titanium.XML.Node.textContent](Titanium.XML.Node.textContent) instead.

Content (value) of all text nodes within this node.

### TEXT_NODE

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only
- Value: `3`

Used with [nodeType](https://titaniumsdk.com/docs/sdk/Titanium.XML.Node.md#nodeType) to identify a
[Text](https://titaniumsdk.com/docs/sdk/Titanium.XML.Text.md) node.

### textContent

- Type: String
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Content (value) of all text nodes within this node.

On Android, `textContent` is supported on [Element](https://titaniumsdk.com/docs/sdk/Titanium.XML.Element.md) and
[Text](https://titaniumsdk.com/docs/sdk/Titanium.XML.Text.md) nodes only.

## Methods

### appendChild

- Platforms: Android, iPhone, iPad, macOS

Appends the node `newChild` as a child of this node.

On iOS, `appendChild` is supported on [Element](https://titaniumsdk.com/docs/sdk/Titanium.XML.Element.md)
nodes **only**.

Parameters:

- `newChild` (Titanium.XML.Node): New node to append.

Returns: Titanium.XML.Node - Newly-appended node.

### cloneNode

- Platforms: Android, iPhone, iPad, macOS

Returns a duplicate of this node.

Parameters:

- `deep` (Boolean): Whether or not to perform a deep copy of this node.

Returns: Titanium.XML.Node - Cloned node.

### hasAttributes

- Platforms: Android, iPhone, iPad, macOS

Returns `true` if this node has attributes.

Returns: Boolean - True if this node has attributes, false if it does not.

### hasChildNodes

- Platforms: Android, iPhone, iPad, macOS

Returns `true` if this node has child nodes.

Returns: Boolean - True if this node has children, false if it does not.

### insertBefore

- Platforms: Android, iPhone, iPad, macOS

Inserts the node `newChild` before the node `refChild`.

On iOS, `insertBefore` is supported on [Element](https://titaniumsdk.com/docs/sdk/Titanium.XML.Element.md)
nodes **only**.

Parameters:

- `newChild` (Titanium.XML.Node): Node to insert.
- `refChild` (Titanium.XML.Node): Node to insert `newChild` before.

Returns: Titanium.XML.Node - The inserted node.

### isSupported

- Platforms: Android, iPhone, iPad, macOS

Tests whether the DOM implementation supports a specific feature.

Parameters:

- `feature` (String): Name of the feature.
- `version` (String): Version number of the feature.

Returns: Boolean - True if the feature is supported, false if it is not.

### normalize

- Platforms: Android

Normalizes text and attribute nodes in this node's child hierarchy.

### removeChild

- Platforms: Android, iPhone, iPad, macOS

Removes a child node from this node.

On iOS, `removeChild` is supported on [Element](https://titaniumsdk.com/docs/sdk/Titanium.XML.Element.md)
nodes **only**.

Parameters:

- `oldChild` (Titanium.XML.Node): Node to remove.

Returns: Titanium.XML.Node - Node that was removed.

### replaceChild

- Platforms: Android, iPhone, iPad, macOS

Replaces the node `oldChild` with the node `newChild`.

On iOS, `replaceChild` is supported on [Element](https://titaniumsdk.com/docs/sdk/Titanium.XML.Element.md)
nodes **only**.

Parameters:

- `newChild` (Titanium.XML.Node): New node.
- `oldChild` (Titanium.XML.Node): Node being replaced.

Returns: Titanium.XML.Node - Node that was replaced.

## Inherited members

7 members are inherited. Each is documented on the type that declares it.

- [Titanium.Proxy](https://titaniumsdk.com/docs/sdk/12.7.1/Titanium.Proxy.md): `addEventListener`, `apiName`, `applyProperties`, `bubbleParent`, `fireEvent`, `lifecycleContainer`, `removeEventListener`

---

- This corpus documents Titanium SDK 13.4.1. Anything here that does not name a version describes 13.4.1.
- Titanium is maintained by TiDev. The Appcelerator toolchain is retired: there is no `appc` CLI, no Appcelerator Studio and no hosted build service. The supported CLI is `titanium` on npm, invoked as `ti`.

