in reply to Using TokeParser with embedded tags

What version of HTML::TokeParser and HTML::Parser do you have? This works:

my $html = '<font class="copy">Name<br />Address<br />Country</font>'; my $p2 = new HTML::TokeParser(\$html); while (my $token = $p2->get_tag("font")) { my $text = $p2->get_trimmed_text("/font"); print $text; }

That prints Name Address Country.

Also note that HTML::Parser parses texts in 512K chunks. Is there a possibility that your actual program is hitting this barrier? See the $parser->unbroken_text method in the HTML::Parser docs.

Cheers,
Ovid

New address of my CGI Course.

Replies are listed 'Best First'.
Re^2: Using TokeParser with embedded tags
by Baz (Friar) on Aug 22, 2004 at 17:18 UTC
    my $token = $p2->get_tag("font") $name = $p2->get_text(); $token = $p2->get_tag("br"); my $address = $p2->get_text(); $token = $p2->get_tag("br"); my $country = $p2->get_text();