NAME
HTML::Object::XPath::NodeSet - HTML Object XPath Node Set
SYNOPSIS
use HTML::Object::XPath::NodeSet;
my $set = HTML::Object::XPath::NodeSet->new ||
die( HTML::Object::XPath::NodeSet->error, "\n" );
my $results = $xp->find( '//someelement' );
if( !$results->isa( 'HTML::Object::XPath::NodeSet' ) )
{
print( "Found $results\n" );
exit;
}
foreach my $context ( $results->get_nodelist )
{
my $newresults = $xp->find( './other/element', $context );
# ...
}
VERSION
v0.2.0
DESCRIPTION
This module contains an ordered list of nodes. The nodes each take the same format as described in HTML::Object::XPath.
METHODS
new
You should never have to create a new NodeSet object, as it is all done for you by HTML::Object::XPath.
append
Given a nodeset
, this appends the list of nodes in nodeset
to the end of the current list.
get_node
Provided with an integer representing a position
and this returns the node at position
.
The node position in XPath is based at 1, not 0.
get_nodelist
Returns a list of nodes. See HTML::Object::XPath for the format of the nodes.
getChildNodes
Returns a list of all elements' own child nodes by calling getChildNodes
on each one of them.
getElementById
Returns a list of all elements' own id by calling getElementById
on each one of them.
getRootNode
Returns the first element's value of getRootNode
new_literal
Returns a new HTML::Object::XPath::Literal object, passing it whatever arguments was provided.
new_number
Returns a new HTML::Object::XPath::Number object, passing it whatever arguments was provided.
pop
Equivalent to perl's "pop" in perlfunc function. This removes the last element from our stack and returns it.
prepend
Given a nodeset
, prepends the list of nodes in nodeset
to the front of the current list.
push
Provided with a list of nodes and this will add them to the stack in this object.
Equivalent to perl's "push" in perlfunc function.
remove_duplicates
This removes any duplicates there might be in our internal list of elements.
reverse
This method reverse the order of the elements in our internal list of elements.
shift
Equivalent to perl's "shift" in perlfunc function.
size
Returns the number of nodes in the HTML::Object::XPath::NodeSet.
sort
This method sorts all the elements by comparing them to one another using cmp
string_value
Returns the string-value of the first node in the list.
See the HTML::Object::XPath specification for what "string-value" means.
string_values
Returns a list of the string-values of all the nodes in the list.
to_boolean
Returns true if there are elements in our internal array of elements, or false otherwise.
to_final_value
Returns a string resulting from the concatenation of each elements' string value.
to_literal
Returns the concatenation of all the string-values of all the nodes in the list.
to_number
Returns a new number object from the value returned from "to_literal"
unshift
Provided with a list of nodes and this will add them at the top of the stack in this object.
Equivalent to perl's "unshift" in perlfunc function.
AUTHOR
Jacques Deguest <jack@deguest.jp>
SEE ALSO
HTML::Object::XPath, HTML::Object::XPath::Boolean, HTML::Object::XPath::Expr, HTML::Object::XPath::Function, HTML::Object::XPath::Literal, HTML::Object::XPath::LocationPath, HTML::Object::XPath::NodeSet, HTML::Object::XPath::Number, HTML::Object::XPath::Root, HTML::Object::XPath::Step, HTML::Object::XPath::Variable
COPYRIGHT & LICENSE
Copyright(c) 2021 DEGUEST Pte. Ltd.
All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.