HTML-Query
view release on metacpan or search on metacpan
returns a reference to the results array.
my $query = HTML::Query->new(\@args);
my $results = $query->query($spec);
my @elements = $results->query($spec)->get_elements();
my $elements = $results->query($spec)->get_elements();
get_specificity()
Calculate the specificity for any given passed selector, a critical
factor in determining how best to apply the cascade
A selector's specificity is calculated as follows:
* count the number of ID attributes in the selector (= a) * count the
number of other attributes and pseudo-classes in the selector (= b) *
count the number of element names in the selector (= c) * ignore
pseudo-elements.
The specificity is based only on the form of the selector. In
particular, a selector of the form "[id=p33]" is counted as an attribute
selector (a=0, b=0, c=1, d=0), even if the id attribute is defined as an
"ID" in the source document's DTD.
See the following spec for additional details:
<http://www.w3.org/TR/CSS21/cascade.html#specificity>
size()
Returns the number of elements in the query.
first()
Returns the first element in the query.
my $elem = $query->first;
If the query is empty then an exception will be thrown. If you would
lib/HTML/Query.pm view on Meta::CPAN
}
# return elements stored from last query
sub get_elements {
my $self = shift;
return wantarray ? @{$self->{elements}} : $self->{elements};
}
###########################################################################################################
# from CSS spec at http://www.w3.org/TR/CSS21/cascade.html#specificity
###########################################################################################################
# A selector's specificity is calculated as follows:
#
# * count the number of ID attributes in the selector (= a)
# * count the number of other attributes and pseudo-classes in the selector (= b)
# * count the number of element names in the selector (= c)
# * ignore pseudo-elements.
#
# Concatenating the three numbers a-b-c (in a number system with a large base) gives the specificity.
#
lib/HTML/Query.pm view on Meta::CPAN
the results array.
my $query = HTML::Query->new(\@args);
my $results = $query->query($spec);
my @elements = $results->query($spec)->get_elements();
my $elements = $results->query($spec)->get_elements();
=head2 get_specificity()
Calculate the specificity for any given passed selector, a critical factor in determining how best to apply the cascade
A selector's specificity is calculated as follows:
* count the number of ID attributes in the selector (= a)
* count the number of other attributes and pseudo-classes in the selector (= b)
* count the number of element names in the selector (= c)
* ignore pseudo-elements.
The specificity is based only on the form of the selector. In particular, a selector of the form "[id=p33]" is counted
as an attribute selector (a=0, b=0, c=1, d=0), even if the id attribute is defined as an "ID" in the source document's DTD.
See the following spec for additional details:
L<http://www.w3.org/TR/CSS21/cascade.html#specificity>
=head2 size()
Returns the number of elements in the query.
=head2 first()
Returns the first element in the query.
my $elem = $query->first;
( run in 0.693 second using v1.01-cache-2.11-cpan-49f99fa48dc )