InfoCenter Home >
4: Developing applications >
4.2: Building Web applications >
4.2.3: Incorporating XML >
4.2.3.6: Using DOM to incorporate XML documents into applications >
4.2.3.6.1: Quick reference to DOM object interfaces

4.2.3.6.1: Quick reference to DOM object interfaces

This section highlights a few of the object interfaces. Refer to the DOM Specification for details (see article 4.1.1.2).

Node methods

Node methods include:

Method Description
hasChildNodes Returns a boolean to indicate whether a node has children
appendNode Appends a new child node to the end of the list of children for a parent node
insertBefore Inserts a child node before the existing child node
removeChild Removes the specified child node from the node list and returns the node
replaceChild Replaces the specified child node with the specified new node and returns the new node

Document methods

The Document object represents the entire XML document. Document methods include:

Method Description
createElement Creates and returns an Element (tag) of the type specified. If the document will be validated against a DTD, that DTD must contain an Element declaration for the created element.
createTextNode Creates a Text node that contains the specified string
createComment Creates a Comment node with the specified content (enclosed within <!-- and --> tags)
createAttribute Creates an Attribute node of the specified name. Use the setAttribute method of Element to set the value of the Attribute. If the document will be validated against a DTD, that DTD must contain an Attribute declaration for the created attribute.
createProcessingInstruction Creates a Processing Instruction with the specified name and data (enclosed within <? and ?> tags). A processing instruction is an instruction to the application (such as an XML document formatter) that receives the XML document.

Element methods

Element node methods include:

Method Description
getAttribute Returns the value of the specified attribute or empty string
setAttribute Adds a new attribute-value pair to the element
removeAttribute Removes the specified attribute from the element
getElementsByTagName Returns a list of the element descendants that have the specified tag name

A Text node can be a child of an Element or Attribute node and contains the textual content (character data) for the parent node. If the content does not include markup, all of the content is placed within a single Text node. If the content includes markup, that markup is placed in one or more Text nodes that are siblings of the Text node that contains the non-markup content.

The Text node extends the CharacterData interface, which has methods for setting, getting, replacing, inserting, and making other modifications to a Text node. In addition to those methods, the Text node adds a method:

Method Description
splitText Splits the Text node at the specified offset. Returns a new Text node, which contains the original content starting at the offset. The original Text node contains the content from the beginning to the offset.
Go to previous article: Using DOM to incorporate XML documents into applications Go to next article: Manually generating an XML element node

 

 
Go to previous article: Using DOM to incorporate XML documents into applications Go to next article: Manually generating an XML element node