http://qs321.pair.com?node_id=717646

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I am trying to parse HTML that contains pseudo HTML tags using HTML::TokeParser but am running into a brick wall.

The HTML looks like this...

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

My code below will parse the HTML fine, but I lose the HTML markup between the <CDATA>...</CDATA> tags.

How can I retain the HTML markup between these <CDATA> tags??

my $p = HTML::TokeParser->new( \$sample_HTML ); while (my $token = $p->get_tag('cdata')){ my $text = $p->get_trimmed_text("/cdata"); print "Found Data: $text\n"; }
This code returns all HTML stripped out - Not good.

Found Data: Just some random whatever. It might have some real HTML like a table or CSS styling or even some IMPORTANT words. Maybe even a form ...