Reputation: 75
I am trying to get the sum of a column in an html table. The first row of this table is all titles. Every cell of every row past the first has the class "right", so I was going to use that class as a selector to ignore the unnecessary titles. However, I only need the second cell of each row. How do I combine these two selectors? Is this right?
my $tree = HTML::TreeBuilder::XPath->new_from_file($fileName);
foreach $value ($tree->findnodes('//table/tr/td[@class="right"[position()=2]')){
stuff;
}
Upvotes: 1
Views: 290
Reputation: 241938
You can combine the predicates by just putting one after another:
//table/tr/td[@class="right"][2]
or, you can use the logical and
//table/tr/td[@class="right" and position()=2]
Upvotes: 2