| XML::DOM::Node(3pm) | User Contributed Perl Documentation | XML::DOM::Node(3pm) |
XML::DOM::Node - Super class of all nodes in XML::DOM
XML::DOM::Node is the super class of all nodes in an XML::DOM document. This means that all nodes that subclass XML::DOM::Node also inherit all the methods that XML::DOM::Node implements.
Attr getName
AttDef getName
AttlistDecl getName
CDATASection "#cdata-section"
Comment "#comment"
Document "#document"
DocumentType getNodeName
DocumentFragment "#document-fragment"
Element getTagName
ElementDecl getName
EntityReference getEntityName
Entity getNotationName
Notation getName
ProcessingInstruction getTarget
Text "#text"
XMLDecl "#xml-declaration"
Not In DOM Spec: AttDef, AttlistDecl, ElementDecl and XMLDecl were added for completeness.
NOTE: this implementation does not return a "live" NodeList for getElementsByTagName. See CAVEATS.
When this method is called in a list context, it returns a regular perl list containing the child nodes. Note that this list is not "live". E.g.
@list = $node->getChildNodes; # returns a perl list
$nodelist = $node->getChildNodes; # returns a NodeList (object reference)
for my $kid ($node->getChildNodes) # iterate over the children of $node
If newChild is a DocumentFragment object, all of its children are inserted, in the same order, before refChild. If the newChild is already in the tree, it is first removed.
Return Value: The node being inserted.
DOMExceptions:
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.
Raised if newChild was created from a different document than the one that created this node.
Raised if this node is readonly.
Raised if refChild is not a child of this node.
Return Value: The node replaced.
DOMExceptions:
Raised if this node is of a type that does not allow children of the type of the newChild node, or it the node to put in is one of this node's ancestors.
Raised if newChild was created from a different document than the one that created this node.
Raised if this node is readonly.
Raised if oldChild is not a child of this node.
Return Value: The node removed.
DOMExceptions:
Raised if this node is readonly.
Raised if oldChild is not a child of this node.
Return Value: The node added.
DOMExceptions:
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.
Raised if newChild was created from a different document than the one that created this node.
Raised if this node is readonly.
Return Value: 1 if the node has any children, 0 otherwise.
Cloning an Element 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 Text node. Cloning any other type of node simply returns a copy of this node.
Parameters:
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).
Return Value: The duplicate node.
Not In DOM Spec: In the DOM Spec this method is defined in the Element and Document class interfaces only, but it doesn't hurt to have it here...
Parameters:
name The name of the tag to match on. The special value
"*" matches all tags.
recurse Whether it should return only direct child nodes (0) or
any descendant that matches the tag name (1). This argument is optional
and defaults to 1. It is not part of the DOM spec.
Return Value: A list of matching Element nodes.
NOTE: this implementation does not return a "live" NodeList for getElementsByTagName. See CAVEATS.
When this method is called in a list context, it returns a regular perl list containing the result nodes. E.g.
@list = $node->getElementsByTagName("tag"); # returns a perl list
$nodelist = $node->getElementsByTagName("tag"); # returns a NodeList (object ref.)
for my $elem ($node->getElementsByTagName("tag")) # iterate over the result nodes
Croaks: if the file could not be opened for writing.
$node->printToFileHandle (\*STDOUT);
$f = new FileHandle ("file.out", "w");
$node->print ($f);
Return Value: the index or -1 if the node is not found.
Return Value: the last child if it was a Text node or else the new Text node.
This method does nothing when called on a Document node.
$node->to_sax (DocumentHandler => $my_handler,
Handler => $handler2 );
%HANDLERS may contain the following handlers:
Default handler when one of the above is not specified
Each XML::DOM::Node generates the appropriate SAX callbacks (for the appropriate SAX handler.) Different SAX handlers can be plugged in to accomplish different things, e.g. XML::Checker would check the node (currently only Document and Element nodes are supported), XML::Handler::BuildDOM would create a new DOM subtree (thereby, in essence, copying the Node) and in the near future, XML::Writer could print the node. All Perl SAX related work is still in flux, so this interface may change a little.
See PerlSAX for the description of the SAX interface.
$query = new XML::XQL::Query ( @XQL_OPTIONS );
return $query->solve ($node);
If the first parameter in @XQL_OPTIONS is the XQL expression, you can leave off the 'Expr' keyword, so:
$node->xql ("doc//elem1[@attr]", @other_options);
is identical to:
$node->xql (Expr => "doc//elem1[@attr]", @other_options);
See XML::XQL::Query for other available XQL_OPTIONS. See XML::XQL and XML::XQL::Tutorial for more info.
| 2022-10-14 | perl v5.34.0 |