in reply to Who has used HTML::Parser??
But version 3 looks like it allows you to specify which functions to use for start end and text in the constructor (see the documentation for an example of this).#!/usr/bin/perl use strict; { package SampleParser; use base qw(HTML::Parser); sub start { my ($self, $tagname, $attr, $attrseq, $origtext) = @_; my $at; print "Tag: $tagname\n"; foreach $at (@{$attrseq}) { print "Attribute: $at = $attr->{$at}\n"; } } sub text { my ($self, $origtext) = @_; print "Text: $origtext\n"; } } my $html = '<html><head><title>this is the title</title><body bgcolor= +"white">Hello</body></html>'; my $sp = new SampleParser; $sp->parse($html)
|
|---|