NAME
XML::GDOME::Node - Interface Node implementation.
SYNOPSIS
$nnm = $n->getAttributes();
$nodeList = $n->getChildNodes();
$node = $n->getFirstChild();
$node = $n->getLastChild();
$str = $n->getLocalName();
$str = $n->getNamespaceURI();
$node = $n->getNextSibling();
$str = $n->getNodeName();
$type = $n->getNodeType();
$str = $n->getNodeValue();
$n->setNodeValue($str);
$doc = $n->getOwnerDocument();
$node = $n->getParentNode();
$str = $n->getPrefix();
$n->setPrefix($str);
$node = $n->getPreviousSibling();
$node = $n->appendChild($newChild);
$node = $n->cloneNode($deep);
$bool = $n->hasAttributes();
$bool = $n->hasChildNodes();
$node = $n->insertBefore($newChild,$refChild);
$bool = $n->isSupported($feature,$version);
$n->normalize();
$node = $n->removeChild($oldChild);
$node = $n->replaceChild($newChild,$oldChild);
$bool = $n->canAppend($newChild);
$str = $n->toString($mode);
@nodes = $n->findnodes($xpath);
$n->iterator( \&nodehandler )
METHODS
- $nnm = $n->getAttributes();
-
Returns: a NamedNodeMap containing the attributes of this node (if it is an Element) or undef otherwise. In array context, returns array.
- $nodeList = $n->getChildNodes();
-
Returns: a NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes. Note that attributes are not considered to be children of element nodes - use gdome_n_attributes to obtain the attributes. In array context, returns array.
- $node = $n->getFirstChild();
-
Returns: the first child of this node. If there is no such node, this returns undef.
- $node = $n->getLastChild();
-
Returns: the last child of this node. If there is no such node, this returns undef.
- $str = $n->getLocalName();
-
Returns: the local part of the qualified name of this node. For nodes of any type other than ELEMENT and ATTRIBUTE and nodes created with a DOM Level 1 method, this is always undef.
- $str = $n->getNamespaceURI();
-
Returns: the namespace URI of this node, or undef if it is unspecified. For nodes of any type other than ELEMENT and ATTRIBUTE and nodes created with a DOM Level 1 method, this is always undef.
- $node = $n->getNextSibling();
-
Returns: the node immediately following this node. If there is no such node, this returns undef.
- $str = $n->getNodeName();
-
Returns: the name of this node, depending on its type.
- $type = $n->getNodeType();
-
Returns: an integer bigger than 0 representing the type of the underlying object or 0 on error.
- $str = $n->getNodeValue();
-
Returns: the value of this node, depending on its type.
- $doc = $n->getOwnerDocument();
-
Returns: the documment object associated with this node. This is also the Document object used to create new nodes. When this node is a Document or a DocumentType which is not used with any Document yet, this is undef.
- $node = $n->getParentNode();
-
Returns: the parent of this node. All nodes, except Attr, Document, DocumentFragment, Entity, and Notation 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 undef.
- $str = $n->getPrefix();
-
Returns: the namespace prefix of this node, or undef if it is unspecified. For nodes of any type other than ELEMENT and ATTRIBUTE and nodes created with a DOM Level 1 method, this is always undef.
- $node = $n->getPreviousSibling();
-
Returns: the node immediately preceding this node. If there is no such node, this returns undef.
- $node = $n->appendChild($newChild);
-
Adds the node newChild to the end of the list of children of this node. If the newChild is already in the tree, it is first removed. If it is a DocumentFragment node, the entire contents of the document fragment are moved into the child list of this node
newChild
: The node to addReturns: the node added.
GDOME_HIERARCHY_REQUEST_ERR
: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to append is one of this node's ancestors or this node itself.GDOME_WRONG_DOCUMENT_ERR
: Raised if newChild was created from a different document than the one that created this node.GDOME_NO_MODIFICATION_ALLOWED_ERR
: Raised when the node is readonly. - $node = $n->cloneNode($deep);
-
Makes a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent; (parentNode is undef). DOCUMENT_TYPE, NOTATION and ENTITY nodes are not supported.
deep
: If true, recursively clone the subtree under the specified node; if false, clone only the node itself (and its attributes, if it is an Element).Returns: the duplicate node.
GDOME_NOT_SUPPORTED_ERR
: Raised if the type of node being cloned is not supported. - $bool = $n->hasAttributes();
-
Returns: 1 if this node has any attributes, 0 otherwise.
- $bool = $n->hasChildNodes();
-
Returns: 1 if this node has any children, 0 otherwise.
- $node = $n->insertBefore($newChild,$refChild);
-
Inserts the node newChild before the existing child node refChild. If refChild is undef, insert newChild at the end of the list of children. If newChild is a DocumentFragment node, all of its children are inserted, in the same order, before refChild. If the newChild is already in the tree, it is first removed.
newChild
: The new node to put in the child listrefChild
: the reference node, i.e., the node before which the new node must be inserted.Returns: the node being inserted.
GDOME_HIERARCHY_REQUEST_ERR
: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to insert is one of this node's ancestors or this node itself.GDOME_NOT_FOUND_ERR
: Raised if refChild is not a child of this node.GDOME_WRONG_DOCUMENT_ERR
: Raised if newChild was created from a different document than the one that created this node.GDOME_NO_MODIFICATION_ALLOWED_ERR
: Raised when the node is readonly. - $bool = $n->isSupported($feature,$version);
-
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.
feature
: The name of the feature to test.version
: This is the version number of the feature to test. In Level 2, version 1, this is the string "2.0". If the version is not specified, supporting any version of the feature will cause the method to return 1.Returns: 1 if the specified feature is supported on this node, 0 otherwise.
- $n->normalize();
-
Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes.
- $node = $n->removeChild($oldChild);
-
Removes the child node indicated by oldChild from the list of children, and returns it.
oldChild
: The node being removedReturns: the node removed.
GDOME_NOT_FOUND_ERR
: Raised if oldChild is not a child of this node.GDOME_NO_MODIFICATION_ALLOWED_ERR
: Raised when the node is readonly. - $node = $n->replaceChild($newChild,$oldChild);
-
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node. If newChild is a DocumentFragment object, oldChild is replaced by all of the DocumentFragment children, which are inserted in the same order. If the newChild is already in the tree, it is first removed.
newChild
: The new node to put in the child listoldChild
: The node being replaced in the listReturns: the node replaced.
GDOME_HIERARCHY_REQUEST_ERR
: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to put in is one of this node's ancestors or this node itself.GDOME_NOT_FOUND_ERR
: Raised if oldChild is not a child of this node.GDOME_WRONG_DOCUMENT_ERR
: Raised if newChild was created from a different document than the one that created this node.GDOME_NO_MODIFICATION_ALLOWED_ERR
: Raised when the node is readonly. - $bool = $n->canAppend($newChild);
-
Tests if a newChild can be added in the child list of this node.
newChild
: The Node Object ref of the node to testReturns: 1 if newChild can be added, 0 otherwise.
- $str = $n->toString($mode);
-
This is the equivalent to XML::GDOME::Document::toString for a single node. This means a node and all its childnodes will be dumped into the result string. There is no formating implemented yet, which may cause an unreadable output.
Returns: string representation of node and childnodes
- @nodes = $n->findnodes($xpath);
-
findnodes performs the xpath statement on the current node and returns the result as an array.
- $n->iterator( \&nodehandler )
-
This is little helper function, that lets one define a function, that will be processed on the current node and all its children. The function will recieve as its only parameter the node to proceed. The function uses inorder proceeding to traverse the subtree. Therefore you can't reach the childnodes anymore, if the nodehandler removes childnodes.
$node->iterator( sub { print $_[0]->nodeName(), "\n"; } );
The example will print all node names in the current subtree.
Returns: return value of the nodehandler while processing the last child of the current node.