Parsing HTML using TreeBuilder - how to get the "next" tag?

Discussion in 'Perl Misc' started by Bruce Horrocks, Jun 12, 2005.

  1. I have a large (6Mb) HTML file that has been generated by a software
    application's "document" function which I am trying to parse using
    HTML::TreeBuilder. It consists of lots of lines in the form:

    <p> Text text text text text
    <p> Text text text text text
    ....
    <p> Text text text text text
    <h1>Section Heading</h1>
    <p> Blah blah blah blah
    <p> Blah blah blah blah
    <p> Blah blah blah blah
    ....

    I can use $tree->look_down() to find the h1 heading but then, how do I
    get the next line? All the examples assume that the thing you want is a
    *child* of the heading, not the *next* tag.

    This requirement seems to be so basic that I must be missing something
    but I can't see what. Perl is ActiveState 5.8.6 on Win32.

    Thanks in advance

    --
    Bruce Horrocks
    Surrey
    England
    <firstname>@<surname>.plus.com -- fix the obvious for email
     
    Bruce Horrocks, Jun 12, 2005
    #1
    1. Advertising

  2. In message <>, Bruce Horrocks
    <> writes
    >I can use $tree->look_down() to find the h1 heading but then, how do I
    >get the next line? All the examples assume that the thing you want is a
    >*child* of the heading, not the *next* tag.


    Okay, found it (I think)
    HTML::Element->right() looks to be what I'm after. Sorry for the noise.

    Regards,
    --
    Bruce Horrocks
    Surrey
    England
    <firstname>@<surname>.plus.com -- fix the obvious for email
     
    Bruce Horrocks, Jun 12, 2005
    #2
    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. shruds
    Replies:
    1
    Views:
    871
    John C. Bollinger
    Jan 27, 2006
  2. Deniz Bahar
    Replies:
    2
    Views:
    492
    Andrey Tarasevich
    Mar 9, 2005
  3. John W. Kennedy

    Equivalent of Perl HTML::TreeBuilder?

    John W. Kennedy, Jul 29, 2004, in forum: Ruby
    Replies:
    2
    Views:
    144
  4. Replies:
    7
    Views:
    1,416
  5. Dean Karres

    HTML::TreeBuilder issue

    Dean Karres, Feb 5, 2009, in forum: Perl Misc
    Replies:
    6
    Views:
    207
    Larry Gates
    Feb 13, 2009
Loading...

Share This Page