Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
TableContentParser(3) User Contributed Perl DocumentationTableContentParser(3)

NAME
       HTML::TableContentParser	- Do interesting things	with the contents of
       tables.

SYNOPSIS
	 use HTML::TableContentParser;
	 $p = HTML::TableContentParser->new();
	 $tables = $p->parse($html);

DESCRIPTION
       This package pulls out the contents of a	table from a string containing
       HTML.  Each time	a table	is encountered,	data will be stored in an
       array consisting	of a hash of whatever was discovered about the table
       -- id, name, border, cellspacing	etc, and of course data	contained
       within the table.

       The format of each hash will look something like

	 attributes	       keys from the attributes	of the <table> tag
	 @{$table_headers}     array of	table headers, in order	found
	 @{$table_rows}	       rows discovered,	in order

       If the table has	a caption, this	will be	provided as

	 caption	       keys from the caption tag's attributes
	   data		       the text	of the <caption>..</caption> element

       then for	each table row,
	   @{$table_data}      td's found, in order
	   other attributes    the ... in <tr ...>

       then for	each data cell,
	     data	       what comes between <td> and </td>
	     other attributes  the ... in <td ...>

   EXAMPLE
	 use HTML::TableContentParser;
	 $p = HTML::TableContentParser->new();
	       $html = read_html_from_somewhere();
	 $tables = $p->parse($html);
	 for $t	(@$tables) {
	   for $r (@{$t->{rows}}) {
			       print "Row: ";
	     for $c (@{$r->{cells}}) {
	       print "[$c->{data}] ";
	     }
	     print "\n";
	   }
	 }

METHODS
       start($parser, $tag, $attr, $attrseq, $origtext);
	   Called whenever a particular	start tag has been recognised. This is
	   called automatically	by the parser and should not be	called from
	   the application.

       text($parser, $content);
	   Called whenever a piece of content is encountered. This is called
	   automatically by the	parser and should not be called	from the
	   application.

       end($parser, $tag, $origtext);
	   Called whenever a particular	end tag	is encountered.	This is	called
	   automatically by the	parser and should not be called	from the
	   application.

       $tables_ref = $p->parse($html);
	   Called with the HTML	to parse. This is all the application needs to
	   do.	The return value will be an arrayref containing	each table
	   encountered,	in the format detailed above.

       DEBUG
	   Not a method, but a class variable. Set to 1	to cause debugging
	   output (basically the structure and content of the table) to	be
	   sent	to stdout via warn().

   EXPORTS
       Nothing.

   CAVEATS, BUGS, and TODO
AUTHOR
	 Simon Drabble	E<lt>sdrabble@cpan.orgE<gt>

	 (C) 2002  Simon Drabble

       This software is	released under the same	terms as perl.

perl v5.24.1			  2002-07-14		 TableContentParser(3)

NAME | SYNOPSIS | DESCRIPTION | METHODS | AUTHOR

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=HTML::TableContentParser&sektion=3&manpath=FreeBSD+12.0-RELEASE+and+Ports>

home | help