Skip to content
Titanium SDK
Version12.6.1

You are reading 12.6.1. See this page in 13.4.1.

Titanium.XML.Document

proxyAndroidiPhoneiPadmacOSsince Android 0.9, iPhone 0.9, iPad 0.9, macOS 9.2.0

Extends Titanium.XML.NodeTitanium.Proxy

The DOM Document returned from Titanium.XML.parseString.

Implements the DOM Level 2 API 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.

Properties 34

apiName

Stringsince Android 3.2.0, iPhone 3.2.0, iPad 3.2.0, macOS 9.2.0read-only

Inherited from Titanium.Proxy

The name of the API that this proxy corresponds to.

bubbleParent

Booleansince Android 3.0.0, iPhone 3.0.0, iPad 3.0.0, macOS 9.2.0

Inherited from Titanium.Proxy

Indicates if the proxy will bubble an event to its parent.

Default: true

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.

nodeType

Numberread-only

Inherited from Titanium.XML.Node

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.

Methods 27

Inherited from Titanium.Proxy

Adds the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to invoke when the event is fired.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Creates an attribute with the given name.

Parameters
ParametersTypeDescription
nameString

Name for the new attribute.

Returns Titanium.XML.Attr

Attribute object, ready to be added to an element.

Creates an attribute with the given name and namespace.

Parameters
ParametersTypeDescription
namespaceURIString

Namespace URI for the new attribute.

nameString

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

Returns Titanium.XML.Attr

Attribute object, ready to be added to an element.

Creates a Comment with the supplied string data.

Parameters
ParametersTypeDescription
dataString

Comment text.

Returns Titanium.XML.Comment

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

Creates an element with the given tag name.

Parameters
ParametersTypeDescription
tagNameString

Name for the created element.

Returns Titanium.XML.Element

Newly created element.

Create a new element with the given namespace and name.

Parameters
ParametersTypeDescription
namespaceURIString

URI for the namespace the new element belongs to.

nameString

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

Returns Titanium.XML.Element

New namespace-qualified element.

Creates a processing instruction for inserting into the DOM tree.

Parameters
ParametersTypeDescription
targetString

Target part for the processing instruction.

dataString

Data for the processing instruction node.

Returns Titanium.XML.ProcessingInstruction

New processing instruction.

Creates a text node.

Parameters
ParametersTypeDescription
dataString

The string value for the text node.

Returns Titanium.XML.Text

Newly-created text node.

Inherited from Titanium.Proxy

Fires a synthesized event to any registered listeners.

Parameters
ParametersTypeDescription
nameString

Name of the event.

event?Dictionary

A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

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

Parameters
ParametersTypeDescription
elementIdString

A unique ID value for an element to search for.

Returns Titanium.XML.Element

The Element matching the given ID, if any.

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

Parameters
ParametersTypeDescription
tagnameString

Tag name to search for.

Returns Titanium.XML.NodeList

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

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

Parameters
ParametersTypeDescription
namespaceURIString

Namespace URI used for matching elements.

localnameString

Tag name to search for.

Returns Titanium.XML.NodeList

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

Inherited from Titanium.XML.Node

Returns true if this node has attributes.

Returns Boolean

True if this node has attributes, false if it does not.

Inherited from Titanium.XML.Node

Returns true if this node has child nodes.

Returns Boolean

True if this node has children, false if it does not.

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
ParametersTypeDescription
importedNodeTitanium.XML.Node

Node to import.

deepBoolean

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

Returns Titanium.XML.Node

Imported node that belongs now to this document.

Inherited from Titanium.XML.Node

Tests whether the DOM implementation supports a specific feature.

Parameters
ParametersTypeDescription
featureString

Name of the feature.

versionString

Version number of the feature.

Returns Boolean

True if the feature is supported, false if it is not.

Inherited from Titanium.Proxy

Removes the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to remove. Must be the same function passed to addEventListener.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.