Source for file simple.php
Documentation is available at simple.php
* Shows simple usage of SaxFilters, using a single custom filter
# require_once 'XML/SaxFilters.php'; // This is the normal way to do it
# Done to help development
if ( !@include_once 'XML/SaxFilters.php' ) {
define ('XML_SAXFILTERS', '../../');
include_once XML_SAXFILTERS . 'SaxFilters.php';
//---------------------------------------------------------------------
// Define a customer handler class - just displays stuff
/* implements XML_SaxFilters_FilterInterface */
// Parsed output stored here
// For whitespace indentation
// Called when parsing starts
$this->output.= "Parsing started\n";
function open(& $tag,& $attribs)
if ( count($attribs) > 0 )
foreach ( $attribs as $key => $value )
$this->output.=" $sep$key: $value";
// Character data handler
// Called at end of parsing
$this->output.= "Parsing finished\n";
//---------------------------------------------------------------------
<dynamically_typed_languages>
<language name="PHP" version="4.3.2">
PHP is number 1 for building web based applications.
<url>http://www.php.net</url>
<language name="Python" version="2.2.3">
Python is number 1 for cross platform desktop applications.
<url>http://www.python.org</url>
<language name="Perl" version="5.8.0">
Perl is number 1 for text and batch processing.
<url>http://www.perl.org</url>
</dynamically_typed_languages>
//---------------------------------------------------------------------
// This is where the action takes place
// Create the parser (use native SAX extension, StringReader, XML document)
// This uses PEAR::XML_HTMLSax instead
// $parser = & XML_SaxFilters_createParser('HTMLSax','String',$doc);
// Instantiate the filter above
// Add the filter to the parser
if ( ! $parser->parse () ) {
$error = $parser->getError ();
echo $error->getMessage ();
echo '<pre>'. $filter->output. '</pre>';
Documentation generated on Mon, 11 Mar 2019 10:15:11 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|