Problem with arrays or possibly HTML::Element

Discussion in 'Perl' started by Brett, Dec 19, 2003.

  1. Brett

    Brett Guest

    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!
    Brett, Dec 19, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Li Ma
    Replies:
    2
    Views:
    327
    Li Ma
    Jan 14, 2004
  2. Andrew King
    Replies:
    1
    Views:
    303
    John Harrison
    Apr 7, 2004
  3. HANM
    Replies:
    2
    Views:
    715
    Joseph Kesselman
    Jan 29, 2008
  4. Philipp
    Replies:
    21
    Views:
    1,127
    Philipp
    Jan 20, 2009
  5. mwschenckCRL
    Replies:
    0
    Views:
    82
    mwschenckCRL
    Oct 27, 2006
Loading...

Share This Page