Location: PHPKode > scripts > HTMLSax > htmlsax/readme.php
<?
/*
	(c) Copyright by Alexander Zhukov hide@address.com Released under LGPL
	TODO: correct comment handling
*/	

include("StateMachine.class.php");
include("AttributesParser.class.php");
include("HTMLSax.class.php");

// Sample HTML text
$html = "
		<html>
		<head>
		<title>
			my test title
		</title>
		</head>
		<body topmargin=10>
		<h1>A test text</h1>
		example text1
		example text2
		<a href=http://test/?asd>test link</a>
		<img src=\"/images/smile.gif\" width=100 height=100>
		<table width=100% bgcolor=\"black\">
			<tr color=#cceeff>
				<td>cell1</td><td>cell2</td>
			</tr>
		</table>
		</body>
		</html>
		";

class MySax extends HTMLSax
{
	function MySax()
	{
		$this->HTMLSax();
		$this->skipWhitespace = 1; // turn this on if you want to skip whitespace between tags
		$this->trimDataNodes = 1; // turn this on if you want to trim the data nodes 
	}
	
	function handle_data($data)
	{
		echo "data node \"$data\"<br>";
	}

	function handle_start_tag($tag,$attribs)
	{
		echo "start tag \"$tag\"<br>";
	}

	function handle_end_tag($tag)
	{
		echo "end tag \"$tag\"<br>";
	}

	
}

$p = new MySax();
$p->parse($html);

?>
Return current item: HTMLSax