[All Packages]  [Next]

W3C DOM APIs

The Document Object Model (DOM) is an application programming interface (API) for HTML and XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated. In the DOM specification, the term document is used in the broad sense -- increasingly, XML is being used as a way of representing many different kinds of information that may be stored in diverse systems, and much of this would traditionally be seen as data rather than as documents. Nevertheless, XML presents this data as documents, and the DOM may be used to manage this data.

With the DOM, programmers can build documents, navigate their structure, and add, modify, or delete elements and content. Anything found in an HTML or XML document can be accessed, changed, deleted, or added using the DOM, with a few exceptions -- in particular, the DOM interfaces for the XML internal and external subsets have not yet been specified.

One important objective of the W3C specification for the DOM is to provide a standard programming interface that can be used in a wide variety of environments and applications. The DOM is designed to be used with any programming language. Since the DOM standard is object-oriented, for this C adaptation, some changes had to be made:

The implementation of this C DOM interface follows REC-DOM-Level-1-19981001.


Data Structures and Types

boolean Boolean value, TRUE or FALSE
oratext String pointer
xmlcpmod Content model node modifier
xmlctx Master XML parser context
xmlnode Document node
xmlnodes Array of nodes
xmlntype Node type enumeration

DOM Functions

appendChild Append child node to current node
appendData Append character data to end of node's current data
cloneNode Create a new node identical to the current one
createAttribute Create an new attribute for an element node
createCDATASection Create a CDATA_SECTION node
createComment Create a COMMENT node
createDocumentFragment Create a DOCUMENT_FRAGMENT node
createElement Create an ELEMENT node
createEntityReference Create an ENTITY_REFERENCE node
createProcessingInstruction Create a PROCESSING_INSTRUCTION (PI) node
createTextNode Create a TEXT node
deleteData Remove substring from a node's character data
getAttrName Return an attribute's name
getAttrSpecified Return value of attribute's specified flag [DOM getSpecified]
getAttrValue Return an attribute's value (definition) [DOM getValue]
getAttribute Return the value of an attribute
getAttributeIndex Return an element's attribute given its index
getAttributeNode Get an element's attribute node given its name [DOM getName]
getAttributes Return array of element's attributes
getCharData Return character data for a TEXT node [DOM getData]
getCharLength Return length of TEXT node's character data [DOM getLength]
getChildNode Return indexed node from array of nodes [DOM item]
getChildNodes Return array of node's children
getContentModel Returns the content model for an element from the DTD [DOM extension]
getDocument Return top-level DOCUMENT node [DOM extension]
getDocumentElement Return highest-level (root) ELEMENT node
getDocType Return current DTD
getDocTypeEntities Return array of DTD's general entities
getDocTypeName Return name of DTD
getDocTypeNotations Return array of DTD's notations
getElementsByTagName Return list of elements with matching name
getEntityNotation Return an entity's NDATA [DOM getNotation]
getEntityPubID Return an entity's public ID [DOM getPublicId]
getEntitySysID Return an entity's system ID [DOM getSystemId]
getFirstChild Return the first child of a node
getImplementation Return DOM-implementation structure (if defined)
getLastChild Return the last child of a node
getModifier Returns a content model node's '?', '*', or '+' modifier [DOM extension]
getNextSibling Return a node's next sibling
getNamedItem Returns the named node from a list of nodes
getNodeMapLength Returns number of entries in a NodeMap [DOM getLength]
getNodeName Returns a node's name
getNodeType Returns a node's type code (enumeration)
getNodeValue Returns a node's "value", its character data
getNotationPubID Returns a notation's public ID [DOM getPublicId]
getNotationSysID Returns a notation's system ID [DOM getSystemId]
getOwnerDocument Returns the DOCUMENT node containing the given node
getPIData Returns a processing instruction's data [DOM getData]
getPITarget Returns a processing instruction's target [DOM getTarget]
getParentNode Returns a node's parent node
getPreviousSibling Returns a node's "previous" sibling
getTagName Returns a node's "tagname", same as name for now
hasAttributes Determine if element node has attributes [DOM extension]
hasChildNodes Determine if node has children
hasFeature Determine if DOM implementation supports a specific feature
insertBefore Inserts a new child node before the given reference node
insertData Inserts new character data into a node's existing data
isStandalone Determine if document is standalone [DOM extension]
nodeValid Validate a node against the current DTD [DOM extension]
normalize Normalize a node by merging adjacent TEXT nodes
numAttributes Returns number of element node's attributes [DOM extension]
numChildNodes Returns number of node's children [DOM extension]
removeAttribute Removes an element's attribute given its names
removeAttributeNode Removes an element's attribute given its pointer
removeChild Removes a node from its parents list of children
removeNamedItem Removes a node from a list of nodes given its name
replaceChild Replace one node with another
replaceData Replace a substring of a node's character data with another string
setAttribute Sets (adds or replaces) a new attribute for an element node given the attribute's name and value
setAttributeNode Sets (adds or replaces) a new attribute for an element node given a pointer to the new attribute
setNamedItem Sets (adds or replaces) a new node in a parent's list of children
setNodeValue Sets a node's "value" (character data)
setPIData Sets a processing instruction's data [DOM setData]
splitText Split a node's character data into two parts
substringData Return a substring of a node's character data

Data Structures and Types


boolean

oratext

xmlcpmod

xmlctx

xmlnode

xmlnodes

xmlntype


Function Prototypes


appendChild


appendData


cloneNode


createAttribute


createCDATASection


createComment


createDocumentFragment


createElement


createEntityReference


createProcessingInstruction


createTextNode


deleteData


getAttribute


getAttributeIndex


getAttributeNode


getAttributes


getAttrName


getAttrSpecified


getAttrValue


getCharData


getCharLength


getChildNode


getChildNodes


getContentModel


getDocType


getDocTypeEntities


getDocTypeName


getDocTypeNotations


getElementsByTagName


getDocument


getDocumentElement


getEntityNotation


getEntityPubID


getEntitySysID


getFirstChild


getImplementation


getLastChild


getModifier


getNamedItem


getNextSibling


getNodeMapLength


getNodeName


getNodeType


getNodeValue


getNotationPubID


getNotationSysID


getOwnerDocument


getParentNode


getPIData


getPITarget


getPreviousSibling


getTagName


hasAttributes


hasChildNodes


hasFeature


insertBefore


insertData


isStandalone


nodeValid


normalize


numAttributes


numChildNodes


removeAttribute


removeAttributeNode


removeChild


removeNamedItem


replaceChild


replaceData


setAttribute


setAttributeNode


setNamedItem


setNodeValue


setPIData


splitText


substringData