# Titanium.XML.Document
The DOM Document returned from parseString.
# 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
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.
# implementation READONLY
Titanium.XML.DOMImplementation object associated with this document.
# Methods
# createAttribute
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.
- Type
- Titanium.XML.Attr
# createAttributeNS
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.
- Type
- Titanium.XML.Attr
# createCDATASection
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
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.
- Type
- Titanium.XML.Comment
# createDocumentFragment
Creates an empty Titanium.XML.DocumentFragment.
Returns
The empty Titanium.XML.DocumentFragment.
# createElement
Creates an element with the given tag name.
Parameters
Name | Type | Description |
---|---|---|
tagName | String | Name for the created element. |
Returns
Newly created element.
- Type
- Titanium.XML.Element
# createElementNS
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.
- Type
- Titanium.XML.Element
# createEntityReference
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
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
Creates a text node.
Parameters
Name | Type | Description |
---|---|---|
data | String | The string value for the text node. |
Returns
Newly-created text node.
- Type
- Titanium.XML.Text
# getElementById
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.
- Type
- Titanium.XML.Element
# getElementsByTagName
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
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
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.
- Type
- Titanium.XML.Node