1. Go to this page and download the library: Download g-scalvini/xml_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/ */
g-scalvini / xml_htmlsax3 example snippets
// Include HTMLSax
mer handler class
class MyHandler {
function MyHandler(){}
// Opening tags
function openHandler(& $parser,$name,$attrs) {
echo ( 'Open Tag Handler: '.$name );
echo ( 'Attrs:' );
print_r($attrs);
}
// Closing tags
function closeHandler(& $parser,$name) {
echo ( 'Close Tag Handler: '.$name );
}
// Text node handler
function dataHandler(& $parser,$data) {
echo ( 'Data Handler: '.$data );
}
// XML escape handler (e.g. HTML comments)
function escapeHandler(& $parser,$data) {
echo ( 'Escape Handler: '.$data );
}
// Processing instruction handler
function piHandler(& $parser,$target,$data) {
echo ( 'PI Handler: '.$target.' - '.$data );
}
// JSP / ASP markup handler
function jaspHandler(& $parser,$data) {
echo ( 'Jasp Handler: '.$data );
}
}
// Get some HTML document
$doc = file_get_contents('http://www.php.net');
// Instantiate the handler
$handler=new MyHandler();
// Instantiate the parser
$parser=& new XML_HTMLSax3();
// Register the handler with the parser
$parser->set_object($handler);
// Set a parser option
$parser->set_option('XML_OPTION_TRIM_DATA_NODES');
// Set the callback handlers (MyHandler methods)
$parser->set_element_handler('openHandler','closeHandler');
$parser->set_data_handler('dataHandler');
$parser->set_escape_handler('escapeHandler');
$parser->set_pi_handler('piHandler');
$parser->set_jasp_handler('jaspHandler');
// Parse the document
$parser->parse($doc);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.