RE: Parsing HTML



Scott Taylor <mailto:scott@xxxxxxxxxxxxxxx> wrote:

: Is there a better, maybe more eligant, way to do this? I don't
: mind to use HTML::Parser if I could only figure out how.

use HTML::TokeParser;

my $html = q(

This is a line of HTML:people write strange things here<br>
and hardly ever follow proper<p>
syntax A&amp;B suck at spelling as well<br>
So I need to clean it up and strip out all<br>

words less then 3 characters in length.<p>

Later the words will go into an indexer for<br>
searching a database

);

my $p = HTML::TokeParser->new( \$html );

while (my $token = $p->get_token) {
my $string = $p->get_trimmed_text;
$string = "\n$string" if $token->[1] eq 'br';
$string = "\n$string" if $token->[1] eq 'p';
print $string;
}

__END__

HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328

.



Relevant Pages

  • Re: I want to look like James Bond
    ... looks in the pictures so that I can figure how far away I am ... It's a definite improvement on looking like Charles, ... you're the Idiot Simpson and you think you are ... "Be who you are and say what you feel, because those who mind don't ...
    (misc.fitness.weights)
  • Re: I want to look like James Bond
    ... looks in the pictures so that I can figure how far away I am ... hazard a guess as to how much someone can squat by a picture. ... It's a definite improvement on looking like Charles, ... "Be who you are and say what you feel, because those who mind don't ...
    (misc.fitness.weights)
  • Re: I want to look like James Bond
    ... looks in the pictures so that I can figure how far away I am ... hazard a guess as to how much someone can squat by a picture. ... It's a definite improvement on looking like Charles, ... "Be who you are and say what you feel, because those who mind don't ...
    (misc.fitness.weights)
  • Re: hi
    ... You can thank Charles for that - CHARLES DROVE HIM AWAY ... Why do you think my mind is severely fucked up? ... toll and that you are clearly a touch doolally tap! ...
    (misc.fitness.weights)
  • Re: So You Sow, So Shall You Reap
    ... There's something for you to aspire to then Charles. ... better qualified "trolls" (which means almost any other bastard ... your mind of the shite that is currently swimming about in there. ... You take a formal course in basic education standards, ...
    (uk.rec.bodybuilding)