1. Go to this page and download the library: Download wackowiki/htmlsax3 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wackowiki / htmlsax3 example snippets
HTMLSax3\HTMLSax3;
// Define a handler object containing your SAX callbacks.
$handler = new class {
public function openHandler(HTMLSax3 $parser, string $tag, array $attrs): void
{
echo "open: <$tag>\n";
print_r($attrs);
}
public function closeHandler(HTMLSax3 $parser, string $tag): void
{
echo "close: </$tag>\n";
}
public function dataHandler(HTMLSax3 $parser, string $data): void
{
echo 'data: ' . trim($data) . "\n";
}
public function escapeHandler(HTMLSax3 $parser, string $data): void
{
echo 'escape: ' . trim($data) . "\n";
}
public function piHandler(HTMLSax3 $parser, string $target, string $data): void
{
echo "pi: <?$target $data
class MyHandler
{
public function openHandler(HTMLSax3 $parser, string $tag, array $attrs): bool;
public function closeHandler(HTMLSax3 $parser, string $tag): bool;
public function dataHandler(HTMLSax3 $parser, string $data): bool;
public function escapeHandler(HTMLSax3 $parser, string $data): bool;
public function piHandler(HTMLSax3 $parser, string $target, string $data): bool;
public function jaspHandler(HTMLSax3 $parser, string $data): bool;
}
// Shim for legacy code that referenced the old root-namespace StateParser.
if (!class_exists('HTMLSax3\StateParser', false)) {
class_alias(\HTMLSax3\States\StateParser::class, 'HTMLSax3\StateParser');
}