Location: PHPKode > scripts > Sax Filters > sax-filters/class_sax_filters.html
<html>
<head>
<title>Sax Filters (class_sax_filters.php)</title>
<link rel="stylesheet" href="main.css" type="text/css">
</head>

<body>
<div align="center">
<table border="0" width="80%" cellpadding="0" cellspacing="0">
<tr>
  <td bgcolor="#aaaaee" class="text" align="center"><a href="http://phpxmlclasses.sourceforge.net/">PHP XML Classes</a></td>
</tr>
</table>
<table border="0" width="80%" cellpadding="0" cellspacing="0">
<tr>
  <td bgcolor="#aaaaee" class="textblbl" align="center">Sax Filters (class_sax_filters.php)</td>
</tr>
</table>
<br/>
<table border="0" width="80%">
<tr>
  <td bgcolor="#eeeeff" class="text">Description: This is a set of classes implementing SAX filters, the classes
include a SAX class to parse XML documents using Expat and defines a way to create SAX filters to perform SAX- based
queries, updates and transformations of documents. Simple filters can be chained to construct augmented complex
XML processors. Interfaces for filters are very easy to define. The classes include a mechanism to stream the
output of "final" filters in order to increase efficiency.
  </td>
</tr>
</table>
<br/>
<table border="0" bgcolor="ddddff" width="80%">
<tr>
  <td valign="top" class="text" width="50%"><b>NEWS:</b>
  <ul>
    <li> 05-17-2002 First version of this set of classes released.
  </ul>
  </td>
  <td valign="top" width="50%" class="text">
     This class code as well as documentation are hosted at <a href="http://www.sourceforge.net">SourceForge</a>
     please visit our <a href="http://www.sourceforge.net/projects/phpxmlclasses/">SourceForge page</a> for releases, documentation, bug-tracking, support
     forums and mailing lists.
  </td>
</tr>
</table>
<br/>
<table border="0" width="80%" cellpadding="0" cellspacing="0">
<tr>
  <td class="textbl" bgcolor="aaaaee" width="50%">Resources</td>
  <td class="textbl" bgcolor="aaaaee" width="50%">Requirements</td>
</tr>
</table>
<table border="1" width="80%" cellpadding="0" cellspacing="0">
<tr>
  <td valign="top" bgcolor="eeeeff" class="text" width="50%">
  <ul>
    <li><a class="textbl" href="http://www.sourceforge.net/projects/phpxmlclasses">Downloads</a>
    <li><a class="textbl" href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/phpxmlclasses/sax_filters/">Browse CVS</a>
    <li><a class="textbl" href="http://sourceforge.net/tracker/?atid=470965&group_id=53613&func=browse">Report Bugs</a>
  </ul>
  </td>
  <td valign="top" bgcolor="eeeeff" class="text" width="50%">
  <ul>
    <li>PHP 4.0.5+
  </ul>
  </td>
</tr>
</table>
<br/>


<table border="0" width="80%" cellpadding="0" cellspacing="0">
<tr>
  <td class="textbl" bgcolor="aaaaee" width="50%">Features</td>
  <td class="textbl" bgcolor="aaaaee" width="50%">To-dos</td>
</tr>
</table>
<table border="1" width="80%" cellpadding="0" cellspacing="0">
<tr>
  <td valign="top" bgcolor="eeeeff" class="text" width="50%">
  <ul>
    <li> Arbietrary filters can be defined
    <li> Filter chains can link any number of filters
    <li> Easy to implement
  </ul>
  </td>
  <td valign="top" bgcolor="ddddff" class="text" width="50%">
  <ul>
    <li> Support for processing instructions
  </ul>
  </td>
  
</tr>
</table>
<br/>
<table border="0" bgcolor="ddddff" width="80%">
<tr>
<!--
  <td valign="top" class="text" width="50%"><b>To-do/future releases:</b>
  <ul>
    <li>Class 
    <li>Class 
    <li>Class 
  </ul>
  </td> -->
  <td valign="top" width="100%" class="text">
     Contact: Luis Argerich (<a href="mailto:hide@address.com">hide@address.com</a>)
  </td>
</tr>
</table>
<br/>
<table border="0" bgcolor="ddddff" width="80%">
<tr>
<!--
  <td valign="top" class="text" width="50%"><b>To-do/future releases:</b>
  <ul>
    <li>Class 
    <li>Class 
    <li>Class 
  </ul>
  </td> -->
  <td valign="top" width="100%" class="text">
    <b>Detailed description and usage:</b>
<br/><br/>This is an overview of the classes that this package defines and how to use
     each one<br/><br/>
     <b>class AbstractSAXParser:</b> This class defines an abstract SAX parser, if you want to build your own
SAX parser or adapt some parser you should implement this class methods. <br/><br/>
What does a SAX parser do? It must parse the XML document and generate "events" that are passed to a listener
object. Note that the parser doesn't process the XML document at all it just parses the documents and generate
events that will be processed by a listener object (An AbstractFilter object).<br/><br/>
Class methods to be implemented are:<br/><br/>
<table border="1">     
       <tr><td class="text">Method</td><td class="text">Description</td></tr>
       <tr><td class="text">AbstractSAXParser()</td><td class="text">The constructor should build the parser and can receive an XML file, for example if needed indicating the XML document to be parsed. How the parser knows where is the document to parse is left free to the parser implementation.</td></tr>
       <tr><td class="text">other optional methods</td><td class="text">Other optional methods allowinf to set XML documents from different sources, parser options etc can be added as needed.</td></tr>
       <tr><td class="text">parse()</td><td class="text">This is the principal method of the class, parsers must parse the XML source and generate the proper events calling the following methods defined in this class: startElementHandler($parser,$name,$attribs)/endElementHandler($parser,$name)/characterDataHandler($data) those methods will call the same methods on the listener object thus propagating SAX events to the listener as they are produced by the parser.</td></tr>
</table>     
<br/>
<b>TIP:</b>Note that you can implement an AbstractSAXParser for non-xml data converting the non-XML data to XML by simply producing events
and then processing the events using filters that are prepared for XML processing.
<br/><br/>
<b>class ExpatParser:</b> This class is an implementation of the AbstractSAXParser class using the PHP built-in expat parser which is, precicesly, a SAX parser.
This version receives the XML as a file receiving the name of the file as an argument of the constructor. The class can be used as following:<br/>
<pre>
$parser = new ExpatParser("foo1.xml");
$filter=new SomeFilterHere();
$parser->setListener($filter);
$parser->parse();
</pre><br/>
Note that all the processing is done at the filter so it is time to see what a filter is (keeo reading, it's easy!)<br/><br/>
<b>class AbstractFilter:</b>Filters are objects that receive SAX events (from a parser or another filter), process them
doing something useful and then pass the events to another filter or output the result in some way, filters that don't
propagate events are called "finalizer" filters and are typically filters that output the document to the browser or
a file.<br/><br/>
Filters must extend the AbstractFilter class implementing the following methods:<br/><br/>
<table border="1">
<tr><td class="text">startElementHandler($name,$attribs)</td><td class="text">This method is called when an element starts in the XML document, the method receives the element names as well as an array of asociative arrays with the
element's attirbutes. A filter can artificially call this method to "create" elements in the result.</td></tr>
<tr><td class="text">endElementHandler($name)</td><td class="text">This method is called when an element ends. It receives the name of the element.</td></tr>
<tr><td class="text">characterDataHandler($data)</td><td class="text">This method is called when text data occurs in the XML document note that context is not provided so the filter
object must keep track of the context if needed using variable members, an stack or smilar methods.</td></tr>
<tr><td class="text">Other methods</td><td class="text">Other methods specific to what the filter should do may be added as well.</td></tr>
</table>
<br/>
Besides that methods all filters have a predefined "setListener" method that allows you to set a listener object
for the filter events what is needed to propagate events from one filter to another.
<br/><br/>
As an example two filters are provided in the package: FilterName and FilterNameBold, FilterName converts all the
&lt;name&gt;something&lt;/name&gt; elements uppercasin its content for example to &lt;name&gt;SOMETHING&lt;/name&gt;<br/><br/>
The FilterNameBold adds a "bold" element to all name elements thus converting &lt;name&gt;something&lt;/name&gt; into
&lt;name&gt;&lt;b&gt;something&lt;/b&gt;&lt;/name&gt;
<br/><br/>
The FilterOutput method is a "finalizer" filter that doesn't propagate events, it just outputs the XML content to the browser.
So it is useful as the last filter in filter chains for testing.
<br/><br/>
If you want to convert all name elements to uppercase you use the classes as follows:
<br/>
<pre>
include_once("class_sax_filters.php");
$f1=new ExpatParser("applications.xml");
$f1->parserSetOption(XML_OPTION_CASE_FOLDING,0);
$f2=new FilterName();
$f3=new FilterOutput();
$f2->setListener($f3);
$f1->setListener($f2);
$f1->parse();
</pre>
<br/>
We create an Expat parser, a FilterName object and a FilterOutput object.<br/><br/>
First we set the FilterOutput as the FilterName listener, what means that events created by FilterName
will be passed to FilterOutput.<br/><br/>
Then we set the FilterName as the parser listener what means that events generated at the parser level
will be propagated to FilterName and since FilterName passes events to FilterOutput that will be the last
link in the filter chain.<br/><br/>
The order in which listeners are set is very important since when we set the parser listener that object
must already have been set with a listener in order to do something.
<br/><br/>
Then we just call the parse method. What will happen is that the parser will parse the XML document generating
events, the events will be passed to filterName where name elements are uppercased and then the events will
be propagated to filterOutput where the content is just printed.
<br/><br/>
Filter Chains can be as complex as you want linking several filters to produce a complex task. Filters can
add elements, remove elements (absorbing events) and change elements thus allowing any kind of XML processing
from queries to transformations.
<br/><br/>
SAX filters are a sound way to modularize SAX processing of XML documents. When documents are very large or
huge only a SAX based processing is efficient since SAX never reads the whole document in memory it just
processes the document chunk by chunk. 
  
<br/>
<h3>Documentation</h3>
</div>

<h2>Classes</h2>
<ul>
  <li><a href="#class23">AbstractSAXParser</a></li>
  <li><a href="#class24">AbstractFilter</a></li>
  <li><a href="#class25">ExpatParser</a></li>
  <li><a href="#class26">FilterOutput</a></li>
</ul>

<a name="class23"></a>
<h3>AbstractSAXParser</h3>
Extends: None<hr>
Description: This is an abstract class defininf the methods that SAX parsers must implement in order to be able to work with SAX filters. <hr>
<br>

<!-- METHOD SUMMARY -->
<A NAME="pDomNode_method_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>

<!-- A ROW -->
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
          <TD><CODE><B><A HREF="#class23method1">AbstractSAXParser</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructor</TD>
</TR>
<!-- A ROW -->
<!-- A ROW -->
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
          <TD><CODE><B><A HREF="#class23method2">parse</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Parses the XML source</TD>
</TR>
<!-- A ROW -->
<!-- A ROW -->
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
          <TD><CODE><B><A HREF="#class23method3">setListener</A></B>(Object $obj)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the parser's listener</TD>
</TR>
<!-- A ROW -->
</TABLE>
&nbsp;
<P>
<!-- METHOD SUMMARY -->


<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>


<!--  method -->
<A NAME="class23method1"><!-- --></A>
<H3>AbstractSAXParser</H3>



<PRE>
void <B>AbstractSAXParser</B>()</PRE>
               
<DL>
<DD>The constructor may or may not receive arguments pointing to the XML source to be parsed, this heavily depends on the parser itself, we may have parsers for XML files, parsers for XML files or XML strings etc.<DD>&nbsp;
<DL>
<DT><B>Parameters:</B><DD>
                          <DT><B>Returns:</B><DD><DT><B>Throws:</B><DD><CODE>None</CODE>
</DL>
</DD>
</DL>
<HR>
<!-- a method -->
<!--  method -->
<A NAME="class23method2"><!-- --></A>
<H3>parse</H3>



<PRE>
void <B>parse</B>()</PRE>
               
<DL>
<DD>This method parses the XML source specified to the parser in some way. While parsing this method must call the proper methods in order to propagate events to this class' listener. The methods to be called are startElementHandler($parser,$name,$attribs), endElementHandler($parser,$name) and characterDataHandler($data). Note that these methods must not be implemented by the parser.<DD>&nbsp;
<DL>
<DT><B>Parameters:</B><DD>
                          <DT><B>Returns:</B><DD><DT><B>Throws:</B><DD><CODE>None</CODE>
</DL>
</DD>
</DL>
<HR>
<!-- a method -->
<!--  method -->
<A NAME="class23method3"><!-- --></A>
<H3>setListener</H3>



<PRE>
void <B>setListener</B>(Object $obj)</PRE>
               
<DL>
<DD>This method sets the listener to a parser object. The listener is a Filter object extending the AbstractFilter class that will receive the events generated by the parser and do something with them.<DD>&nbsp;
<DL>
<DT><B>Parameters:</B><DD>
                          $obj - An object of a Filter class extending the AbstractFilter class<br><DT><B>Returns:</B><DD><DT><B>Throws:</B><DD><CODE>None</CODE>
</DL>
</DD>
</DL>
<HR>
<!-- a method -->
<!-- ============ METHOD DETAIL ========== -->
<a name="class24"></a>
<h3>AbstractFilter</h3>
Extends: None<hr>
Description: This class defines the methods that must be implemented by a Filter. <hr>
<br>

<!-- METHOD SUMMARY -->
<A NAME="pDomNode_method_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>

<!-- A ROW -->
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
          <TD><CODE><B><A HREF="#class24method1">setListener</A></B>(object $obj)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the Filter's listener object</TD>
</TR>
<!-- A ROW -->
<!-- A ROW -->
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
          <TD><CODE><B><A HREF="#class24method2">startElement</A></B>(string $name, array $attribs)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Method that is called when an XML element starts</TD>
</TR>
<!-- A ROW -->
<!-- A ROW -->
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
          <TD><CODE><B><A HREF="#class24method3">endElement</A></B>(string $name)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Method that is called when an element ends</TD>
</TR>
<!-- A ROW -->
<!-- A ROW -->
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
          <TD><CODE><B><A HREF="#class24method4">characterDataHandler</A></B>(string $data)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Method that will be called when text data is found</TD>
</TR>
<!-- A ROW -->
</TABLE>
&nbsp;
<P>
<!-- METHOD SUMMARY -->


<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>


<!--  method -->
<A NAME="class24method1"><!-- --></A>
<H3>setListener</H3>



<PRE>
void <B>setListener</B>(object $obj)</PRE>
               
<DL>
<DD>This method defines an object that will be used as a listener for events propagated from a Filter. This method is already implemented in the abstract class so Filters don't have to implement it.<DD>&nbsp;
<DL>
<DT><B>Parameters:</B><DD>
                          $obj - An object from a class extending the AbstractFilter class<br><DT><B>Returns:</B><DD><DT><B>Throws:</B><DD><CODE>None</CODE>
</DL>
</DD>
</DL>
<HR>
<!-- a method -->
<!--  method -->
<A NAME="class24method2"><!-- --></A>
<H3>startElement</H3>



<PRE>
void <B>startElement</B>(string $name, array $attribs)</PRE>
               
<DL>
<DD>This method should be implemented by Filters, the method receives the name of the element and its attributes. What the method does depends on the filter.<DD>&nbsp;
<DL>
<DT><B>Parameters:</B><DD>
                          $name - Name of th element<br>$attribs - This is an array of associative arrays containing the attributes for the element. You can process it using
a construct like: foreach($attribs as $name=>$value) { }<br><DT><B>Returns:</B><DD><DT><B>Throws:</B><DD><CODE>None</CODE>
</DL>
</DD>
</DL>
<HR>
<!-- a method -->
<!--  method -->
<A NAME="class24method3"><!-- --></A>
<H3>endElement</H3>



<PRE>
void <B>endElement</B>(string $name)</PRE>
               
<DL>
<DD>This method should be implemented by filters, it will be called when an XML element ends<DD>&nbsp;
<DL>
<DT><B>Parameters:</B><DD>
                          $name - Name of the element that ends<br><DT><B>Returns:</B><DD><DT><B>Throws:</B><DD><CODE>None</CODE>
</DL>
</DD>
</DL>
<HR>
<!-- a method -->
<!--  method -->
<A NAME="class24method4"><!-- --></A>
<H3>characterDataHandler</H3>



<PRE>
void <B>characterDataHandler</B>(string $data)</PRE>
               
<DL>
<DD>This method should be implemented by filters, the method will be called when text is found in an XML document, the method can be called several times for the same text node (by chunks) and no context information is provided, the filter should track context if it needs to know, for example, the name of the element where text was found<DD>&nbsp;
<DL>
<DT><B>Parameters:</B><DD>
                          $data - The text chunk found<br><DT><B>Returns:</B><DD><DT><B>Throws:</B><DD><CODE>None</CODE>
</DL>
</DD>
</DL>
<HR>
<!-- a method -->
<!-- ============ METHOD DETAIL ========== -->
<a name="class25"></a>
<h3>ExpatParser</h3>
Extends: AbstractSAXParser<hr>
Description: This is an implementation of the AbstractSAXParser class using the PHP internal Expat parser<hr>
<br>

<!-- METHOD SUMMARY -->
<A NAME="pDomNode_method_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>

<!-- A ROW -->
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
          <TD><CODE><B><A HREF="#class25method1">ExpatParser</A></B>(string $xmlfile)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructor</TD>
</TR>
<!-- A ROW -->
<!-- A ROW -->
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
          <TD><CODE><B><A HREF="#class25method2">parse</A></B>(string $xmlfile)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Parses the XML document</TD>
</TR>
<!-- A ROW -->
<!-- A ROW -->
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
          <TD><CODE><B><A HREF="#class25method3">setListener</A></B>(object $obj)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the listener object of the ExpatParser</TD>
</TR>
<!-- A ROW -->
<!-- A ROW -->
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
          <TD><CODE><B><A HREF="#class25method4">parserSetOption</A></B>(constant $option, some $value)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets options for the Expat parser</TD>
</TR>
<!-- A ROW -->
</TABLE>
&nbsp;
<P>
<!-- METHOD SUMMARY -->


<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>


<!--  method -->
<A NAME="#class25method1"><!-- --></A>
<H3>ExpatParser</H3>



<PRE>
void <B>ExpatParser</B>(string $xmlfile)</PRE>
               
<DL>
<DD>The constructor receives the name of the XML file to be parsed.<DD>&nbsp;
<DL>
<DT><B>Parameters:</B><DD>
                          $xmlfile - Name of the file containing the XML document to be parsed<br><DT><B>Returns:</B><DD><DT><B>Throws:</B><DD><CODE>None</CODE>
</DL>
</DD>
</DL>
<HR>
<!-- a method -->
<!--  method -->
<A NAME="#class25method2"><!-- --></A>
<H3>parse</H3>



<PRE>
void <B>parse</B>(string $xmlfile)</PRE>
               
<DL>
<DD>This method parses the XML file pointedby the filename indicated when the parser was constructed. The method will parse the document and propagate events to the listener object. A setListener method must havebeen used before parsing.<DD>&nbsp;
<DL>
<DT><B>Parameters:</B><DD>
                          <DT><B>Returns:</B><DD><DT><B>Throws:</B><DD><CODE>None</CODE>
</DL>
</DD>
</DL>
<HR>
<!-- a method -->
<!--  method -->
<A NAME="#class25method3"><!-- --></A>
<H3>setListener</H3>



<PRE>
void <B>setListener</B>(object $obj)</PRE>
               
<DL>
<DD>This method is used to set the listenerObject for the parser: the first Filter in the chain. The object must be an instance of a class extending the AbstractFilter object.<DD>&nbsp;
<DL>
<DT><B>Parameters:</B><DD>
                          $obj - An object from a class implementing the AbstractFilter class<br><DT><B>Returns:</B><DD><DT><B>Throws:</B><DD><CODE>None</CODE>
</DL>
</DD>
</DL>
<HR>
<!-- a method -->
<!--  method -->
<A NAME="#class25method4"><!-- --></A>
<H3>parserSetOption</H3>



<PRE>
void <B>parserSetOption</B>(constant $option, some $value)</PRE>
               
<DL>
<DD>Sets options for the Expat parser<DD>&nbsp;
<DL>
<DT><B>Parameters:</B><DD>
                          $option - For example XML_OPTION_CASE_FOLDING to set if case folding is applied or not to the document. (See the PHP documentation for options that can be set for an Expat parser)<br>$value - Value for the option being set<br><DT><B>Returns:</B><DD><DT><B>Throws:</B><DD><CODE>None</CODE>
</DL>
</DD>
</DL>
<HR>
<!-- a method -->
<!-- ============ METHOD DETAIL ========== -->
<a name="#class26"></a>
<h3>FilterOutput</h3>
Extends: AbstractFilter<hr>
Description: This is a finalizer filter that must be used always at the end of a filter chain. This filter absorbs SAX events ouputting the XML document to the browser.<hr>
<br>

<!-- METHOD SUMMARY -->
<A NAME="pDomNode_method_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>

<tr><td><p align=center>This class doesn´t have any method</p></td></tr></TABLE>
&nbsp;
<P>
<!-- METHOD SUMMARY -->


<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>
<tr><td><p align=center>This class doesn´t have any method</p></td></tr><!-- ============ METHOD DETAIL ========== -->
</td>
</tr>
</table>

</body>
</html>
Return current item: Sax Filters