Class HTML_Head_Parser

Description

HTML Head Parser - Parses <head> section of a HTML document

This class is based on HeadParser.pm <http://search.cpan.org/author/GAAS/HTML-Parser-3.28/lib/HTML/HeadParser.pm> by Gisle Aas. A lot of the documentation here has been copied from the perl files.

HTML_Head_Parser will only parse the <HEAD>...</HEAD> section of an HTML document. The parse() method will return a FALSE value as soon as some <BODY> element or body text are found, and should not be called again after this.

HTML_Head_Parser keeps a reference to a header object, and the parser will update this header object as the various elements of the <HEAD> section of the HTML document are recognized. The following header fields are affected:

  • Content-Base: The Content-Base header is initialized from the <base href="..."> element.
  • Title: The Title header is initialized from the <title>...</title> element.
  • X-Meta-Foo: All <meta> elements will initialize headers with the prefix "X-Meta-" on the name. If the <meta> element contains a http-equiv attribute, then it will be honored as the header name.
Example:

1 require_once(HTTPNAV_ROOT.'HTML_Head_Parser.php');
2 $parser =& new HTML_Head_Parser();
3 // parse HTML, will return false when body tags/text detected
4 $parser->parse($html);
5 // return a HTTP_Headers object
6 $headers =& $parser->get_headers();

Located in Program_Root/HTML_Head_Parser.php (line 45)


	
			
Variable Summary
Method Summary
void eof ()
string get_header (header $name)
object &get_headers ()
bool parse (string $input, [bool $final = false])
void set_headers (object &$headers)
void _cdata_handler (mixed &$parser, mixed $data)
void _end_handler (mixed &$parser, mixed $element)
void _flush_text ()
void _start_handler (mixed &$parser, mixed $element, mixed $atts)
Variables
object HTTP_Headers $headers (line 57)

Headers

object HTML_Parser $parser (line 51)

HTML Parser

string $tag (line 63)

Tag - name of active element that takes textual content

string $text (line 69)

Text - the accumulated text associated with the element

Methods
Constructor HTML_Head_Parser (line 74)

Constructor

void HTML_Head_Parser ()
eof (line 104)

End of file

Indicates end of file

void eof ()
get_header (line 132)

Get header value

  • return:

    header value

string get_header (header $name)
  • header $name:

    name

get_headers (line 122)

Get headers object

object &get_headers ()
parse (line 93)

Parse HTML

  • return:

    returns false to indicate end of header, true otherwise

bool parse (string $input, [bool $final = false])
  • string $input
  • bool $final:

    set to true if $input is the last chunk of the document.

set_headers (line 113)

Set headers object

void set_headers (object &$headers)
  • object $headers
_cdata_handler (line 190)
void _cdata_handler (mixed &$parser, mixed $data)
_end_handler (line 184)
void _end_handler (mixed &$parser, mixed $element)
_flush_text (line 202)
void _flush_text ()
_start_handler (line 137)
void _start_handler (mixed &$parser, mixed $element, mixed $atts)

Documention generated on Wed, 16 Jul 2003 01:03:09 +0100 by phpDocumentor 1.2.0