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. Advertisements

  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. Advertisements

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:
    1,270
    John C. Bollinger
    Jan 27, 2006
  2. Greg Aumann
    Replies:
    0
    Views:
    399
    Greg Aumann
    Jun 28, 2006
  3. Replies:
    1
    Views:
    581
    Andrew Thompson
    Nov 29, 2006
  4. Deniz Bahar
    Replies:
    2
    Views:
    746
    Andrey Tarasevich
    Mar 9, 2005
  5. John W. Kennedy

    Equivalent of Perl HTML::TreeBuilder?

    John W. Kennedy, Jul 29, 2004, in forum: Ruby
    Replies:
    2
    Views:
    254
  6. afrinspray

    FormatText/TreeBuilder Removes Line Breaks

    afrinspray, Sep 8, 2005, in forum: Perl Misc
    Replies:
    4
    Views:
    216
    afrinspray
    Sep 21, 2005
  7. Replies:
    7
    Views:
    1,811
  8. Dean Karres

    HTML::TreeBuilder issue

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