Problem with arrays or possibly HTML::Element

B

Brett

Hello All,

I'm trying to parse through a webpage, and I used HTML::treebuilder to
try to get it into an easily managable data structure. I am having a
bit of trouble parsing through it though.

Here is a snippet of code:

$tree = HTML::TreeBuilder->new;
$tree->parse($response->content);
$tree->eof();
my @tables = $tree->look_down("_tag", "table");
my $root = $tables[0]; # Move to first table
@tables = $root->look_down("_tag","tr");
$root = $tables[2]; # Move to third row


The problem is, at the end of this snippet if I dump the contents of
$root I get the FIRST row of the table, rather than the third.
Somehow it always assigns the first element of the table instead of
the one I specify in the brackets.

If anyone has an idea about what I'm doing wrong I would really
appreciate it. I was asked to write this script for a professor's
research and I am late on delivering it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top