# Titanium.XML.Document

The DOM Document returned from parseString.

Availability
0.9
0.9
9.2.0

# Overview

Implements the DOM Level 2 API (opens new window) on Android and iOS.

As of version 3.1, Android does not truly support DTDs. A document with a DTD can be parsed, however it is not validated, its default attributes are not be automatically added into the DOM tree, and so on.

This has been reported as Android Issue #7395 (opens new window).

# Properties

# doctype READONLY

Availability
0.9
0.9
9.2.0

An interface to the list of entities that are defined for the document, such as via a Document Type Definition (DTD).

See note about Android and DTDs.


# documentElement READONLY

Availability
0.9
0.9
9.2.0
documentElement :Titanium.XML.Element

Root element of this document.


# implementation READONLY

Availability
0.9
0.9
9.2.0

Titanium.XML.DOMImplementation object associated with this document.

# Methods

# createAttribute

Availability
0.9
0.9
9.2.0
createAttribute(name) Titanium.XML.Attr

Creates an attribute with the given name.

Parameters

Name Type Description
name String

Name for the new attribute.

Returns

Attribute object, ready to be added to an element.


# createAttributeNS

Availability
0.9
0.9
9.2.0
createAttributeNS(namespaceURI, name) Titanium.XML.Attr

Creates an attribute with the given name and namespace.

Parameters

Name Type Description
namespaceURI String

Namespace URI for the new attribute.

name String

Qualified name for the new attribute (can include a prefix).

Returns

Attribute object, ready to be added to an element.


# createCDATASection

Availability
0.9
0.9
9.2.0
createCDATASection(data) Titanium.XML.CDATASection

Creates and returns a Titanium.XML.CDATASection.

Parameters

Name Type Description
data String

String data to go into the CDATA section.

Returns

CDATA section with the given data, ready to be added to an element.


# createComment

Availability
0.9
0.9
9.2.0
createComment(data) Titanium.XML.Comment

Creates a Titanium.XML.Comment with the supplied string data.

Parameters

Name Type Description
data String

Comment text.

Returns

Comment object, ready to be appended to the DOM tree.


# createDocumentFragment

Availability
0.9
0.9
9.2.0
createDocumentFragment() Titanium.XML.DocumentFragment

Returns

The empty Titanium.XML.DocumentFragment.


# createElement

Availability
0.9
0.9
9.2.0
createElement(tagName) Titanium.XML.Element

Creates an element with the given tag name.

Parameters

Name Type Description
tagName String

Name for the created element.

Returns

Newly created element.


# createElementNS

Availability
0.9
0.9
9.2.0
createElementNS(namespaceURI, name) Titanium.XML.Element

Create a new element with the given namespace and name.

Parameters

Name Type Description
namespaceURI String

URI for the namespace the new element belongs to.

name String

Qualified for the new element (can include a prefix).

Returns

New namespace-qualified element.


# createEntityReference

Availability
0.9
0.9
9.2.0
createEntityReference(name) Titanium.XML.EntityReference

Creates an Titanium.XML.EntityReference with the given name.

Parameters

Name Type Description
name String

Name for the new entity reference.

Returns

Newly-created entity reference.


# createProcessingInstruction

Availability
0.9
0.9
9.2.0
createProcessingInstruction(target, data) Titanium.XML.ProcessingInstruction

Creates a processing instruction for inserting into the DOM tree.

Parameters

Name Type Description
target String

Target part for the processing instruction.

data String

Data for the processing instruction node.

Returns

New processing instruction.


# createTextNode

Availability
0.9
0.9
9.2.0
createTextNode(data) Titanium.XML.Text

Creates a text node.

Parameters

Name Type Description
data String

The string value for the text node.

Returns

Newly-created text node.


# getElementById

Availability
0.9
0.9
9.2.0
getElementById(elementId) Titanium.XML.Element

Returns an Titanium.XML.Element that has an ID attribute with the given value.

Parameters

Name Type Description
elementId String

A unique ID value for an element to search for.

Returns

The Element matching the given ID, if any.


# getElementsByTagName

Availability
0.9
0.9
9.2.0
getElementsByTagName(tagname) Titanium.XML.NodeList

Returns a node list of elements in the document which have the given tag.

Parameters

Name Type Description
tagname String

Tag name to search for.

Returns

List of elements in the document which have the given tag name.


# getElementsByTagNameNS

Availability
0.9
0.9
9.2.0
getElementsByTagNameNS(namespaceURI, localname) Titanium.XML.NodeList

Returns a node list of elements in the document which belong to the given namespace and have the given tag name.

Parameters

Name Type Description
namespaceURI String

Namespace URI used for matching elements.

localname String

Tag name to search for.

Returns

List of elements in the document which belong to the given namespace and have the given tag name.


# importNode

Availability
0.9
0.9
9.2.0
importNode(importedNode, deep) Titanium.XML.Node

Imports a node from another document to this document, without altering or removing the source node from the original document.

This method creates a new copy of the source node, ready to be inserted into this document. The returned node has an ownerDocument property that points to this document, but its parentNode property is null, since it has not been inserted into the current document.

For more on node ownership, see ownerDocument issues in the W3C DOM FAQ.

Parameters

Name Type Description
importedNode Titanium.XML.Node

Node to import.

deep Boolean

If true, recursively import the subtree under the specified node; if false, import only the node itself.

Returns

Imported node that belongs now to this document.