NAME

HTML::FormParser - Do things with the contents of HTML forms.

SYNOPSIS

  use HTML::FormParser;
  $p = HTML::FormParser->new();
  $p->parse($html, form => sub { ... }, input => sub { ... });
	

DESCRIPTION

An object-oriented module inheriting from HTML::Parser. HTML::FormParser takes a string containing HTML text and parses it, looking for forms.

Since this package inherits from HTML::Parser, only the API unique to HTML::FormParser is described.

Each type of tag that might be found in a form can have three kinds of action associated with it via callbacks. Callbacks are passed to the parse() method, and take up to three forms.

o  start_${tagname}  Called whenever $tagname is opened.
o  ${tagname}        Called immediately after start_${tagname}, and
                     immediately before end_${tagname}.
o  end_${tagname}    Called whenever a closing $tagname is encountered.

Each of these callbacks will be passed the attributes and original tag text as parameters, when called.

EXAMPLE

  use HTML::FormParser;
  $p = HTML::FormParser->new();
  $p->parse($html,
      start_form => sub {
        my ($attr, $origtext) = @_;
        print "Form action is $attr->{action}\n";
      });
  
	

METHODS

start($parser, $tag, $attr, $attrseq, $origtext);

Called whenever a particular start tag has been recognised. This module recognises these tags: <form>, <input>, <textarea> & <select>.

This method will be called by the parser and is not intended to be called from an application.

end($parser, $tag, $origtext);

Called whenever a particular end tag is encountered.

This method will be called by the parser and is not intended to be called from an application.

$p->parse($html, tag_type => \&coderef, ...);

This method is all you really need to do. Call it with callbacks for each tag type. These will be executed as described above.

EXPORTS

Nothing.

CAVEATS, BUGS, and TODO

o $p->parse() should ideally accept different forms for the html parameter, for example it should read from a stream or filehandle.

AUTHOR

Simon Drabble <sdrabble@cpan.org> (C) 2002 Simon Drabble

This software is released under the same terms as perl.