# Titanium.XML.CharacterData

> An interface extending [Titanium.XML.Node](https://titaniumsdk.com/docs/sdk/Titanium.XML.Node.md) with a set of attributes and methods for accessing character data in the DOM. Implements the [DOM Level 2 API](https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-FF21A306) on Android and iOS. For reasons of compatibility with the javascript engine, text is represented by UTF-8 instead of UTF-16 on Android and iOS.

- Source: https://titaniumsdk.com/docs/sdk/12.6.4/Titanium.XML.CharacterData
- Titanium SDK version: 12.6.4
- 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.XML.Node
- Inheritance: Titanium.XML.Node > Titanium.Proxy

## Properties

### data

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

The character data of the node that implements this interface. Throws an exception during setting if this node is readonly.

### length

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

The number of characters that are available through data and the substringData method. This may have the value zero, i.e., [Titanium.XML.CharacterData](https://titaniumsdk.com/docs/sdk/Titanium.XML.CharacterData.md) may be empty.

## Methods

### appendData

- Platforms: Android, iPhone, iPad, macOS

Append the string to the end of the character data of the node. Upon success, data provides access to the concatenation of data and the string specified. Throws an exception if this node is readonly.

Parameters:

- `arg` (String): The string to append.

### deleteData

- Platforms: Android, iPhone, iPad, macOS

Remove a range of characters from the node. Upon success, data and length reflect the change. Throws an exception if this node is readonly, if offset is negative, offset is beyond the data's length, or if count is negative.

Parameters:

- `offset` (Number): The offset from which to start removing.
- `count` (Number): The number of characters to delete. If the sum of offset and count exceeds length then all characters from offset to the end of the data are deleted.

### insertData

- Platforms: Android, iPhone, iPad, macOS

Insert a string at the specified offset. Throws an exception if this node is readonly, if offset is negative, or if offset is beyond the data's length.

Parameters:

- `offset` (Number): The character offset at which to insert.
- `arg` (String): The string to insert.

### replaceData

- Platforms: Android, iPhone, iPad, macOS

Replace the characters starting at the specified offset with the specified string. Throws an exception if this node is readonly, if offset is negative, offset is beyond the data's length, or if count is negative.

Parameters:

- `offset` (Number): The offset from which to start replacing.
- `count` (Number): The number of characters to replace. If the sum of offset and count exceeds length, then all characters to the end of the data are replaced; (i.e., the effect is the same as a remove method call with the same range, followed by an append method invocation).
- `arg` (String): The string with which the range must be replaced.

### substringData

- Platforms: Android, iPhone, iPad, macOS

Extracts a range of data from the node. Throws an exception if offset is negative, offset is beyond the data's length, or if count is negative.

Parameters:

- `offset` (Number): Start offset of substring to extract.
- `count` (Number): The number of characters units to extract.

Returns: String - The specified substring. If the sum of offset and count exceeds the length, then all 16-bit units to the end of the data are returned.

## Inherited members

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

- [Titanium.Proxy](https://titaniumsdk.com/docs/sdk/12.6.4/Titanium.Proxy.md): `addEventListener`, `apiName`, `applyProperties`, `bubbleParent`, `fireEvent`, `lifecycleContainer`, `removeEventListener`
- [Titanium.XML.Node](https://titaniumsdk.com/docs/sdk/12.6.4/Titanium.XML.Node.md): `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`, `appendChild`, `attributes`, `childNodes`, `cloneNode`, `firstChild`, `hasAttributes`, `hasChildNodes`, `insertBefore`, `isSupported`, `lastChild`, `localName`, `namespaceURI`, `nextSibling`, `nodeName`, `nodeType`, `nodeValue`, `normalize`, `ownerDocument`, `parentNode`, `prefix`, `previousSibling`, `removeChild`, `replaceChild`, `text`, `textContent`

---

- 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`.

