Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: HTML::TokeParser Frustration

by wfsp (Abbot)
on Oct 17, 2008 at 07:12 UTC ( [id://717674]=note: print w/replies, xml ) Need Help??


in reply to HTML::TokeParser Frustration

graff has answered your question. fwiw I find HTML::TokeParser::Simple can, imo, help make this sort of task easier.
#!/usr/bin/perl use strict; use warnings; use HTML::TokeParser::Simple; my $sample_HTML = <<EOD; <HTML> blah. <CDATA> Just some random whatever. It might have some <b>real</b> HTML like a +table or CSS styling or even some <H1>IMPORTANT</H1> words. Maybe even a form <form method= +post>...</form> </CDATA> </HTML> EOD my $p = HTML::TokeParser::Simple->new(\$sample_HTML) or die qq{parse failed\n}; my ($in_cdata, $cdata); while (my $t = $p->get_token){ $in_cdata++, next if $t->is_start_tag(q{cdata}); $in_cdata--, next if $t->is_end_tag(q{cdata}); next unless $in_cdata; $cdata .= $t->as_is; } print $cdata;
Just some random whatever. It might have some <b>real</b> HTML like a +table or CSS styling or even some <H1>IMPORTANT</H1> words. Maybe even a form <form method= +post>...</form>

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://717674]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-26 01:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found