class Node

The <code> Node </code> interface is the primary datatype for the entire Document Object Model. More...

Full nameDOM::Node
Definition#include <dom_node.h>
Inherited byAttr, CDATASection, CharacterData, Comment, Document, DocumentFragment, DocumentType, Element, Entity, EntityReference, HTMLAnchorElement, HTMLAppletElement, HTMLAreaElement, HTMLBRElement, HTMLBaseElement, HTMLBaseFontElement, HTMLBlockquoteElement, HTMLBodyElement, HTMLButtonElement, HTMLDListElement, HTMLDirectoryElement, HTMLDivElement, HTMLDocument, HTMLElement, HTMLFieldSetElement, HTMLFontElement, HTMLFormElement, HTMLFrameElement, HTMLFrameSetElement, HTMLHRElement, HTMLHeadElement, HTMLHeadingElement, HTMLHtmlElement, HTMLIFrameElement, HTMLImageElement, HTMLInputElement, HTMLIsIndexElement, HTMLLIElement, HTMLLabelElement, HTMLLegendElement, HTMLLinkElement, HTMLMapElement, HTMLMenuElement, HTMLMetaElement, HTMLModElement, HTMLOListElement, HTMLObjectElement, HTMLOptGroupElement, HTMLOptionElement, HTMLParagraphElement, HTMLParamElement, HTMLPreElement, HTMLQuoteElement, HTMLScriptElement, HTMLSelectElement, HTMLStyleElement, HTMLTableCaptionElement, HTMLTableCellElement, HTMLTableColElement, HTMLTableElement, HTMLTableRowElement, HTMLTableSectionElement, HTMLTextAreaElement, HTMLTitleElement, HTMLUListElement, Notation, ProcessingInstruction, Text
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Protected Members


Detailed Description

The <code> Node </code> interface is the primary datatype for the entire Document Object Model. It represents a single node in the document tree. While all objects implementing the <code> Node </code> interface expose methods for dealing with children, not all objects implementing the <code> Node </code> interface may have children. For example, <code> Text </code> nodes may not have children, and adding children to such nodes results in a <code> DOMException </code> being raised.

The attributes <code> nodeName </code> , <code> nodeValue </code> and <code> attributes </code> are included as a mechanism to get at node information without casting down to the specific derived interface. In cases where there is no obvious mapping of these attributes for a specific <code> nodeType </code> (e.g., <code> nodeValue </code> for an Element or <code> attributes </code> for a Comment), this returns <code> null </code> . Note that the specialized interfaces may contain additional and more convenient mechanisms to get and set the relevant information.

 Node ()

Node

 Node (const Node &other)

Node

 Node ( NodeImpl *_impl)

Node

Node &  operator = (const Node &other)

operator =

bool  operator == (const Node &other)

operator ==

bool  operator != (const Node &other)

operator !=

 ~Node ()

~Node

[virtual]

enum NodeType { ELEMENT_NODE = 1, ATTRIBUTE_NODE = 2, TEXT_NODE = 3, CDATA_SECTION_NODE = 4, ENTITY_REFERENCE_NODE = 5, ENTITY_NODE = 6, PROCESSING_INSTRUCTION_NODE = 7, COMMENT_NODE = 8, DOCUMENT_NODE = 9, DOCUMENT_TYPE_NODE = 10, DOCUMENT_FRAGMENT_NODE = 11, NOTATION_NODE = 12 }

NodeType

An integer indicating which type of node this is.

<p>The values of <code>nodeName</code>, <code>nodeValue</code>, and <code>attributes</code> vary according to the node type as follows: <table border="1"> <tbody> <tr> <td></td> <td>nodeName</td> <td>nodeValue</td> <td>attributes</td> </tr> <tr> <td>Element</td> <td>tagName</td> <td>null</td> <td>NamedNodeMap</td> </tr> <tr> <td>Attr</td> <td>name of attribute</td> <td>value of attribute</td> <td>null</td> </tr> <tr> <td>Text</td> <td>#text</td> <td>content of the text node</td> <td>null</td> </tr> <tr> <td>CDATASection</td> <td>#cdata-section</td> <td>content of the CDATA Section</td> <td>null</td> </tr> <tr> <td>EntityReference</td> <td>name of entity referenced</td> <td>null</td> <td>null</td> </tr> <tr> <td>Entity</td> <td>entity name</td> <td>null</td> <td>null</td> </tr> <tr> <td>ProcessingInstruction</td> <td>target</td> <td>entire content excluding the target</td> <td>null</td> </tr> <tr> <td>Comment</td> <td>#comment</td> <td>content of the comment</td> <td>null</td> </tr> <tr> <td>Document</td> <td>#document</td> <td>null</td> <td>null</td> </tr> <tr> <td>DocumentType</td> <td>document type name</td> <td>null</td> <td>null</td> </tr> <tr> <td>DocumentFragment</td> <td>#document-fragment</td> <td>null</td> <td>null</td> </tr> <tr> <td>Notation</td> <td>notation name</td> <td>null</td> <td>null</td> </tr> </tbody> </table> </p>

DOMString  nodeName ()

nodeName

[const]

The name of this node, depending on its type; see the table above.

DOMString  nodeValue ()

nodeValue

[const]

The value of this node, depending on its type; see the table above.

Throws: DOMException, DOMSTRING_SIZE_ERR:, Raised, when, it, would, return, more, characters, than, fit, in, a, <code>, DOMString, </code>, variable, on, the, implementation, platform.

void  setNodeValue ( const DOMString & )

setNodeValue

see nodeValue

Throws: DOMException, NO_MODIFICATION_ALLOWED_ERR:, Raised, when, the, node, is, readonly.

unsigned short  nodeType ()

nodeType

[const]

A code representing the type of the underlying object, as defined above.

Node  parentNode ()

parentNode

[const]

The parent of this node. All nodes, except <code> Document </code> , <code> DocumentFragment </code> , and <code> Attr </code> may have a parent. However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is <code> null </code> .

NodeList  childNodes ()

childNodes

[const]

A <code> NodeList </code> that contains all children of this node. If there are no children, this is a <code> NodeList </code> containing no nodes. The content of the returned <code> NodeList </code> is &quot;live&quot; in the sense that, for instance, changes to the children of the node object that it was created from are immediately reflected in the nodes returned by the <code> NodeList </code> accessors; it is not a static snapshot of the content of the node. This is true for every <code> NodeList </code> , including the ones returned by the <code> getElementsByTagName </code> method.

Node  firstChild ()

firstChild

[const]

The first child of this node. If there is no such node, this returns <code> null </code> .

Node  lastChild ()

lastChild

[const]

The last child of this node. If there is no such node, this returns <code> null </code> .

Node  previousSibling ()

previousSibling

[const]

The node immediately preceding this node. If there is no such node, this returns <code> null </code> .

Node  nextSibling ()

nextSibling

[const]

The node immediately following this node. If there is no such node, this returns <code> null </code> .

NamedNodeMap  attributes ()

attributes

[const]

A <code> NamedNodeMap </code> containing the attributes of this node (if it is an <code> Element </code> ) or <code> null </code> otherwise.

Document  ownerDocument ()

ownerDocument

[const]

The <code> Document </code> object associated with this node. This is also the <code> Document </code> object used to create new nodes. When this node is a <code> Document </code> this is <code> null </code> .

Node  insertBefore ( const Node &newChild, const Node &refChild )

insertBefore

Inserts the node <code> newChild </code> before the existing child node <code> refChild </code> . If <code> refChild </code> is <code> null </code> , insert <code> newChild </code> at the end of the list of children.

If <code> newChild </code> is a <code> DocumentFragment </code> object, all of its children are inserted, in the same order, before <code> refChild </code> . If the <code> newChild </code> is already in the tree, it is first removed.

WRONG_DOCUMENT_ERR: Raised if <code> newChild </code> was created from a different document than the one that created this node.

NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

NOT_FOUND_ERR: Raised if <code> refChild </code> is not a child of this node.

Parameters:
newChildThe node to insert.
refChildThe reference node, i.e., the node before which the new node must be inserted.

Returns: The node being inserted.

Throws: DOMException, HIERARCHY_REQUEST_ERR:, Raised, if, this, node, is, of, a, type, that, does, not, allow, children, of, the, type, of, the, <code>, newChild, </code>, node, or, if, the, node, to, insert, is, one, of, this, node's, ancestors.

Node  replaceChild ( const Node &newChild, const Node &oldChild )

replaceChild

Replaces the child node <code> oldChild </code> with <code> newChild </code> in the list of children, and returns the <code> oldChild </code> node. If the <code> newChild </code> is already in the tree, it is first removed.

WRONG_DOCUMENT_ERR: Raised if <code> newChild </code> was created from a different document than the one that created this node.

NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

NOT_FOUND_ERR: Raised if <code> oldChild </code> is not a child of this node.

Parameters:
newChildThe new node to put in the child list.
oldChildThe node being replaced in the list.

Returns: The node replaced.

Throws: DOMException, HIERARCHY_REQUEST_ERR:, Raised, if, this, node, is, of, a, type, that, does, not, allow, children, of, the, type, of, the, <code>, newChild, </code>, node, or, it, the, node, to, put, in, is, one, of, this, node's, ancestors.

Node  removeChild ( const Node &oldChild )

removeChild

Removes the child node indicated by <code> oldChild </code> from the list of children, and returns it.

NOT_FOUND_ERR: Raised if <code> oldChild </code> is not a child of this node.

Parameters:
oldChildThe node being removed.

Returns: The node removed.

Throws: DOMException, NO_MODIFICATION_ALLOWED_ERR:, Raised, if, this, node, is, readonly.

Node  appendChild ( const Node &newChild )

appendChild

Adds the node <code> newChild </code> to the end of the list of children of this node. If the <code> newChild </code> is already in the tree, it is first removed.

If it is a <code> DocumentFragment </code> object, the entire contents of the document fragment are moved into the child list of this node

WRONG_DOCUMENT_ERR: Raised if <code> newChild </code> was created from a different document than the one that created this node.

NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

Parameters:
newChildThe node to add.

Returns: The node added.

Throws: DOMException, HIERARCHY_REQUEST_ERR:, Raised, if, this, node, is, of, a, type, that, does, not, allow, children, of, the, type, of, the, <code>, newChild, </code>, node, or, if, the, node, to, append, is, one, of, this, node's, ancestors.

bool  hasChildNodes ( )

hasChildNodes

This is a convenience method to allow easy determination of whether a node has any children.

Returns: <code> true </code> if the node has any children, <code> false </code> if the node has no children.

Node  cloneNode ( bool deep )

cloneNode

Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent ( <code> parentNode </code> returns <code> null </code> .).

Cloning an <code> Element </code> copies all attributes and their values, including those generated by the XML processor to represent defaulted attributes, but this method does not copy any text it contains unless it is a deep clone, since the text is contained in a child <code> Text </code> node. Cloning any other type of node simply returns a copy of this node.

Parameters:
deepIf <code> true </code> , recursively clone the subtree under the specified node; if <code> false </code> , clone only the node itself (and its attributes, if it is an <code> Element </code> ).

Returns: The duplicate node.

void  addEventListener (const DOMString &type, EventListener *listener, const bool useCapture)

addEventListener

Introduced in DOM Level 2 This method is from the EventTarget interface

This method allows the registration of event listeners on the event target. If an EventListener is added to an EventTarget while it is processing an event, it will not be triggered by the current actions but may be triggered during a later stage of event flow, such as the bubbling phase.

If multiple identical EventListeners are registered on the same EventTarget with the same parameters the duplicate instances are discarded. They do not cause the EventListener to be called twice and since they are discarded they do not need to be removed with the removeEventListener method. Parameters

Parameters:
typeThe event type for which the user is registering
listenerThe listener parameter takes an interface implemented by the user which contains the methods to be called when the event occurs.
useCaptureIf true, useCapture indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched to the registered EventListener before being dispatched to any EventTargets beneath them in the tree. Events which are bubbling upward through the tree will not trigger an EventListener designated to use capture.

void  removeEventListener (const DOMString &type, EventListener *listener, bool useCapture)

removeEventListener

Introduced in DOM Level 2 This method is from the EventTarget interface

This method allows the removal of event listeners from the event target. If an EventListener is removed from an EventTarget while it is processing an event, it will not be triggered by the current actions.

EventListeners can never be invoked after being removed.

Calling removeEventListener with arguments which do not identify any currently registered EventListener on the EventTarget has no effect.

Parameters:
typeSpecifies the event type of the EventListener being removed.
listenerThe EventListener parameter indicates the EventListener to be removed.
useCaptureSpecifies whether the EventListener being removed was registered as a capturing listener or not. If a listener was registered twice, one with capture and one without, each must be removed separately. Removal of a capturing listener does not affect a non-capturing version of the same listener, and vice versa.

bool  dispatchEvent (const Event &evt)

dispatchEvent

Introduced in DOM Level 2 This method is from the EventTarget interface

This method allows the dispatch of events into the implementations event model. Events dispatched in this manner will have the same capturing and bubbling behavior as events dispatched directly by the implementation. The target of the event is the EventTarget on which dispatchEvent is called.

Parameters:
evtSpecifies the event type, behavior, and contextual information to be used in processing the event.

Returns: The return value of dispatchEvent indicates whether any of the listeners which handled the event called preventDefault. If preventDefault was called the value is false, else the value is true.Exceptions

Throws: EventException, UNSPECIFIED_EVENT_TYPE_ERR:, Raised, if, the, Event's, type, was, not, specified, by, initializing, the, event, before, dispatchEvent, was, called., Specification, of, the, Event's, type, as, null, or, an, empty, string, will, also, trigger, this, exception.

unsigned short  elementId ()

elementId

[const]

not part of the DOM.

Returns: the element id, in case this is an element, 0 otherwise

bool  isNull ()

isNull

[const]

tests if this Node is 0. Useful especially, if casting to a derived class:


 Node n = .....;
 // try to convert into an Element:
 Element e = n;
 if( e.isNull() )
   kdDebug(300) << "node isn't an element node" << endl;

NodeImpl * handle ()

handle

[const]

unsigned long  index ()

index

[const]

QString  toHTML ()

toHTML

void  applyChanges ()

applyChanges

void  getCursor (int offset, int &_x, int &_y, int &height)

getCursor

QRect  getRect ()

getRect

not part of the DOM.

Returns: the exact coordinates and size of this element.

NodeImpl * impl

impl

[protected]


Generated by: root@daffy.perf.redhat.com on Mon Jul 14 13:28:10 2003, using kdoc 2.0a53.