<?php
/*
* test_get_html_links.php
*
* @(#) $Header: /home/mlemos/cvsroot/markupparser/test_get_html_links.php,v 1.1 2009/06/27 08:37:11 mlemos Exp $
*
*/
require_once('markup_parser.php');
require_once('markup_filter_get_html_links.php');
$message_file = ((IsSet($_SERVER['argv']) && count($_SERVER['argv'])>1) ? $_SERVER['argv'][1] : 'test/sample/simple.html');
$filter = new markup_filter_get_html_links_class;
/* Set to 1 if the you need to track line numbers of errors or element
* positions
*/
$filter->track_lines = 1;
/* Set to 1 if the you need to get the markup data with link tags
*/
$filter->get_link_markup = 1;
/* Set to 1 if the you need to get the only the character data with link tags
*/
$filter->get_only_link_data = 1;
/* Set to 0 if the HTML document is an excerpt and does not contain a body section
*/
$filter->body_search = 1;
$parameters=array(
'File'=>$message_file,
/* Read a markup from a string instead of a file */
/* 'Data'=>'<html><head><title>My HTML data string</title></head>
<body><p><a href="http://www.php.net/">PHP</a></p></body></html>', */
);
if(($success = $filter->StartParsing($parameters)))
{
do
{
if(!($success = $filter->Parse($end, $elements)))
break;
$te = count($elements);
for($e = 0; $e < $te; ++$e)
var_dump($elements[$e]);
}
while(!$end);
if($success)
$success = $filter->FinishParsing();
}
if(!$success)
{
echo 'Markup parsing error: '.$filter->error.' at position '.$filter->error_position;
if($filter->track_lines
&& $filter->GetPositionLine($filter->error_position, $line, $column))
echo ' line '.$line.' column '.$column;
echo "\n";
}
for($warning = 0, Reset($filter->warnings); $warning < count($filter->warnings); Next($filter->warnings), $warning++)
{
$w = Key($filter->warnings);
echo 'Warning: ', $filter->warnings[$w], ' at position ', $w;
if($filter->track_lines
&& $filter->GetPositionLine($w, $line, $column))
echo ' line '.$line.' column '.$column;
echo "\n";
}
?>
|