NAME

domNode   -   Manipulates an instance of a DOM node object

SYNOPSIS

$nodeObject method  ?arg arg ...

DESCRIPTION

This command manipulates one particular instance of a DOM node object. method indicates a specific method of the node class. These methods should closely conform to the W3C recommendation "Document Object Model (Core) Level 1" (http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html) as well to parts of the W3C draft "XML Pointer Language (XPointer)" (http://www.w3.org/TR/1998/WD-xptr-19980303). The selectNodes method implements (partially) the "XML Path Language (XPath) Version 1.0" working draft (13 August 1999) (http://www.w3.org/TR/xpath). Look at these documents for a deeper understanding of the functionality. The valid methods are:

nodeType
Returns the node type of that node object. This can be: ELEMENT_NODE, ATTRIBUTE_NODE, TEXT_NODE, or CDATA_SECTION_NODE.

nodeName
Returns the node name of that node object. This is the element (tag) name for element nodes (type ELEMENT_NODE), "#text" for text node or "#cdata" for cdata section nodes.OB

nodeValue
Returns the value of that node object. This is the the text or the data for element nodes of type TEXT_NODE or CDATA_SECTION_NODE). Otherwise it is empty.

hasChildNodes
Returns 1 if the has children. Otherwise 0 is returned.

childNodes
Returns the parent node.

childNodes
Returns a list of direct children node objects.

firstChild  ?objVar
Returns the first child as a node object.

lastChild  ?objVar
Returns the last child as a node object.

nextSibling  ?objVar
Returns the next sibling relativ to the current node as a node object.

previousSibling  ?objVar
Returns the next sibling relativ to the current node as a node object.

getElementsByTagName name
Returns a list of all elements in the subtree matching (glob style) name.

getAttribute attributeName  ?defaultValue
Returns the value of the attribute attributeName. If attribute is not available defaultValue is returned.

setAttribute attributeName newValue
Sets the value for an attribute attributeName to newValue. This will create a new attribute, if it wasn't avialble before.

removeAttribute attributeName
Removes the attribute attributeName.

attributes  ?attributeNamePattern
Returns all attributes matching the attributeNamePattern. If attributeNamePattern isn't given all attributes are returned as a Tcl list.

hasAttribute attributeName
Returns 1 iff the object node contains an attribute with nam attributeName. Otherwise 0 is returned.

appendChild newChild
Append newChild to the end of the child list of the node. newChild must be in the document fragment list.

insertBefore newChild refChild
Insert newChild before the refChild in list of children of that node. newChild must be in the document fragment list.

replaceChild newChild oldChild
Replace newChild with oldChild in list of children of that node. newChild must be in the document fragment list. oldChild will be part of the document fragment list after this operation.

removeChild child
Removes child from the list of children of that node child will be part of the document fragment list after this operation. It is not physically deleted.

cloneNode  ?-deep
Clones this node and adds the new create node into the document fragment list. If the -deep option is specified, all descendant nodes are also cloned.

ownerDocument
Returns the document object of the document this node belongs to.

find attrName attrVal  ?objVar
Finds the node with the attribute name attrName, and attribute value attrVal in the subtree starting the current node.

child number|all  ?type?   ?attrName attrValue
(XPointer) child

descendant number|all  ?type?   ?attrName attrValue
(XPointer) descendant

ancestor number|all  ?type?   ?attrName attrValue
(XPointer) ancestor

fsibling number|all  ?type?   ?attrName attrValue
(XPointer) fsibling

psibling number|all  ?type?   ?attrName attrValue
(XPointer) psibling

root  ?objVar
(XPointer) root

text
Returns all text node children of that current node combined, i.e. appended into one string.

target
For a processing instruction node the target part is returned. Otherwise an error is generated.

data
For a processing instruction node the data part is returned. Otherwise an error is generated.

selectNodes xpathQuery  ?typeVar
Returns the result of applying the XPath query xpathQuery to the subtree. This can be a string/value, a list of strings, a list of nodes, a list of attribute name and a list of attribute name / value pairs. If typeVar is given the result type name is store into that variable (empty, bool, number, string, nodes, attrnodes, attrvalues).
set paragraphNodes [$node selectNodes {chapter[3]//para[@type='warning' or @type='error'} ]
foreach paragraph $paragraphNodes {
    lappend  values [$paragraph selectNodes attribute::type]
}
      

getLine
Returns the line number of that node in the orignal parsed XML.

getColumn
Returns the column number of that node in the orignal parsed XML.

asList
Returns the DOM substree starting form the current node as a nested Tcl list.

asXML  ?-indent none/1..8
Returns the DOM substree starting form the current node as an indented XML string.

appendFromList list
Parses list, creates an according DOM subtree and appends this subtree to the current node.

appendXML XMLstring
Parses XMLstring, creates an according DOM subtree and appends this subtree to the current node.

simpleTranslate outputVar specifications
Translate the subtree starting at the object node according to the specifications in specifications and outputs the result in the variable outputVar. The translation is very similar to Cost Simple mode.

@attrName
Returns the value of the attribute attrName. Short cut for getAttribute.
Otherwise, if an unknown method name is given, the command with the same name as the given method within the namespace ::dom::domNode is tried to be executed. This allows quick method additions on Tcl level.

PORTABILITY ISSUES

SEE ALSO

 
dom,  domDoc