@node HTML/HeadParser, HTML/LinkExtor, HTML/Formatter, Module List
@unnumbered Parse <HEAD> section of a HTML document


@unnumberedsec NAME

HTML::HeadParser - Parse <HEAD> section of a HTML document

@unnumberedsec SYNOPSIS

@example
require HTML::HeadParser;
$p = HTML::HeadParser->new;
$p->parse($text) and  print "not finished";
@end example

@example
$p->header(@'Title@')          # to access <title>....</title>
$p->header(@'Content-Base@')   # to access <base href="http://...">
$p->header(@'Foo@')            # to access <meta http-equiv="Foo" content="...">
@end example

@unnumberedsec DESCRIPTION

The @emph{HTML::HeadParser} is a specialized (and lightweight)
@emph{HTML::Parser} that will only parse the <HEAD>...</HEAD> section of a
HTML document.  The parse() and parse_file() methods will return a
FALSE value as soon as a <BODY> element is found, and should not be
called again after this.

The @emph{HTML::HeadParser} constructor takes a @emph{HTTP::Headers} object
reference as argument.  The parser will update this header object as
the various head elements are recognized.

The following header fields are initialized from elements found in the
@samp{lt} in this nodehead> section of a HTML document:

@table @asis
@item Content-Base:
The @emph{Content-Base} header is initialized from the <base
href="..."> element.

@item Title:
The @emph{Title} header is initialized from the <title>...</title>
element.

@item Isindex:
The @emph{Isindex} header will be added if there is a <isindex>
element in the <head>.  The header value is initialized from the
@emph{prompt} attribute if it is present.

@item @emph{http-equiv}
Any other header field can be initialized from a <meta
http-equiv="header" content="..."> element.

@end table
@unnumberedsec EXAMPLES

@example
$h = HTTP::Headers->new;
$p = HTML::HeadParser->new($h);
$p->parse(<<EOT);
<title>Stupid example</title>
<base href="http://www.sn.no/libwww-perl/">
Normal text starts here.
EOT
undef $p;
print $h->title;   # should print "Stupid example"
@end example

@unnumberedsec SEE ALSO

@xref{HTML/Parser,HTML/Parser},, @xref{HTTP/Headers,HTTP/Headers},

@unnumberedsec COPYRIGHT

Copyright 1996 Gisle Aas. All rights reserved.

This library is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

@unnumberedsec AUTHOR

Gisle Aas <aas@@sn.no>

