[All Packages]  [This Package]  [Previous Class]  [Next Class]

Class: Document

This class contains methods for creating and retrieving nodes.


Method Index

createAttribute Create an ATTRIBUTE node
createAttributeNS Create an ATTRIBUTE node with namespace information
createCDATASection Create a CDATA node
createComment Create a COMMENT node
createDocumentFragment Create a DOCUMENT_FRAGMENT node
createElement Create an ELEMENT node
createElementNS Create an ELEMENT node with namespace information
createEntityReference Create an ENTITY_REFERENCE node
createProcessingInstruction Create a PROCESSING_INSTRUCTION node
createTextNode Create a TEXT node
getElementByID Returns the element node which has the given ID
getElementsByTagName Select nodes based on tag name
getElementsByTagNameNS Select nodes based on tag name with namespace information
getImplementation Return DTD for document
importNode Copy a node from another document into this document
saveString Allocates memory and saves the given string

Methods

createAttribute

Function:
Create a new attribute node.

Prototype:
Attr* createAttribute(DOMString name, DOMString value)

Arguments:
name -- name of attribute
value -- value of attribute

Returns:
Attr* -- pointer to created node

createAttributeNS

Function:
Create a new attribute node.

Prototype:
Attr* createAttributeNS(DOMString nspuri, DOMString qname, DOMString value)

Arguments:
nspuri -- element's namespace URI
qname -- qualified name of attribute
value -- value of attribute

Returns:
Attr* -- pointer to created node

createCDATASection

Function:
Create a new CDATA node with the given contents.

Prototype:
Attr* createCDATASection(DOMString name)

Arguments:
data -- contents of node

Returns:
CDATASection* -- pointer to created node

createComment

Function:
Create a new comment node with the given contents.

Prototype:
Comment* createComment(DOMString data)

Arguments:
data -- contents of node

Returns:
Comment* -- pointer to created node

createDocumentFragment

Function:
Create a new document fragment node.

Prototype:
DocumentFragment* createDocumentFragment()

Arguments:
None

Returns:
DocumentFragment* -- pointer to created node

createElement

Function:
Create a new element node with the given (tag) name.

Prototype:
Element* createElement(DOMString tagName)

Arguments:
tagName -- element's tagname

Returns:
Element* -- pointer to created node

createElementNS

Function:
Create a new element node with the given (tag) name and namespace information.

Prototype:
Element* createElementNS(DOMString nspuri, DOMString qname)

Arguments:
nspuri -- element's namespace URI
qname -- element's qualified name

Returns:
Element* -- pointer to created node

createEntityReference

Function:
Create a new entity reference node.

Prototype:
EntityReference* createEntityReference(DOMString name)

Arguments:
name -- name of entity to reference

Returns:
EntityReference* -- pointer to created node

createProcessingInstruction

Function:
Create a new processing instruction node.

Prototype:
ProcessingInstruction* createProcessingInstruction(DOMString target, DOMString data)

Arguments:
target -- target part of PI
data -- data for node

Returns:
ProcessingInstruction* -- pointer to created node

createTextNode

Function:
Create a new TEXT node.

Prototype:
Text* createTextNode(DOMString data)

Arguments:
data -- data for node

Returns:
Text* -- pointer to created node

getElementByID

Function:
Returns the element node which has the given ID. If no such ID is defined (or other problems), returns NULL.

Prototype:
Element* getElementByID(DOMString name)

Arguments:
name -- element ID

Returns:
Element* -- element node with given ID

getElementsByTagName

Function:
Returns a NodeList of all the Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the Document tree. If elem is NULL, the entire document is searched. The special value "*" matches all tags.

Prototype:
NodeList* getElementsByTagName(Element *elem, DOMString tagname)

Arguments:
elem -- root node
tagname -- tag name to select

Returns:
NodeList* -- list of matches, NULL if none

getElementsByTagNameNS

Function:
Returns a NodeList of all the Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the Document tree. If elem is NULL, the entire document is searched. The special value "*" matches all tags.

Prototype:
NodeList* getElementsByTagName(Element *elem, DOMString nspuri, DOMString local)

Arguments:
elem -- root node
nspuri -- namespace uri
local -- namespace local name

Returns:
NodeList* -- list of matches, NULL if none

getImplementation

Function:
Returns the DOMImplementation structure, currently useless. Perhaps it will be used in later DOM versions.

Prototype:
DOMImplementation* getImplementation()

Arguments:
None

Returns:
DOMImplementation* -- pointer to structure

importNode

Function:
Imports a node from another document to this document. The returned node has no parent (i.e. it's NULL). The source node is not altered or removed from the original document; this method creates a new copy of the source node. If deep is TRUE, recursively imports the subtree under node; if it's FALSE, imports only the node itself.

Additional information is copied as appropriate to the nodeType, attempting to mirror the behavior expected if a fragment of XML source was copied from one document to another, recognizing that two documents may have different DTDs. See DOM 2.0 spec for specific action taken for each node type.

Prototype:
xmlnode *importNode(xmlctx *ctx, xmlnode *import, boolean deep);

Arguments:
ctx -- XML context
import -- node to be imported
deep -- recursively import subtree?

Returns:
xmlnode* -- pointer to new Node

saveString

Function:
Allocates memory and saves the given string. Use to store locally generated strings.

Prototype:
DOMString saveString(DOMString str);

Arguments:
string -- string to save

Returns:
DOMString -- pointer to saved string