XML_HTMLSax3
[ class tree: XML_HTMLSax3 ] [ index: XML_HTMLSax3 ] [ all elements ]

Source for file HTMLSax3.php

Documentation is available at HTMLSax3.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. //
  4. // +----------------------------------------------------------------------+
  5. // | PHP Version 4                                                        |
  6. // +----------------------------------------------------------------------+
  7. // | Copyright (c) 1997-2002 The PHP Group                                |
  8. // +----------------------------------------------------------------------+
  9. // | This source file is subject to version 2.02 of the PHP license,      |
  10. // | that is bundled with this package in the file LICENSE, and is        |
  11. // | available at through the world-wide-web at                           |
  12. // | http://www.php.net/license/3_0.txt.                                  |
  13. // | If you did not receive a copy of the PHP license and are unable to   |
  14. // | obtain it through the world-wide-web, please send a note to          |
  15. // | license@php.net so we can mail you a copy immediately.               |
  16. // +----------------------------------------------------------------------+
  17. // | Authors: Alexander Zhukov <alex@veresk.ru> Original port from Python |
  18. // | Authors: Harry Fuecks <hfuecks@phppatterns.com> Port to PEAR + more  |
  19. // | Authors: Many @ Sitepointforums Advanced PHP Forums                  |
  20. // +----------------------------------------------------------------------+
  21. //
  22. // $Id: HTMLSax3.php 22138 2007-06-01 10:19:14Z markwest $
  23. //
  24. /**
  25. * Main parser components
  26. @package XML_HTMLSax3
  27. @version $Id: HTMLSax3.php 22138 2007-06-01 10:19:14Z markwest $
  28. */
  29. /**
  30. * Required classes
  31. */
  32. if (!defined('XML_HTMLSAX3')) {
  33.     define('XML_HTMLSAX3''XML/');
  34. }
  35. Loader::requireOnce(XML_HTMLSAX3 'HTMLSax3/States.php');
  36. Loader::requireOnce(XML_HTMLSAX3 'HTMLSax3/Decorators.php');
  37.  
  38. /**
  39. * Base State Parser
  40. @package XML_HTMLSax3
  41. @access protected
  42. @abstract
  43. */
  44.     /**
  45.     * Instance of user front end class to be passed to callbacks
  46.     * @var XML_HTMLSax3 
  47.     * @access private
  48.     */
  49.     var $htmlsax;
  50.     /**
  51.     * User defined object for handling elements
  52.     * @var object 
  53.     * @access private
  54.     */
  55.     var $handler_object_element;
  56.     /**
  57.     * User defined open tag handler method
  58.     * @var string 
  59.     * @access private
  60.     */
  61.     var $handler_method_opening;
  62.     /**
  63.     * User defined close tag handler method
  64.     * @var string 
  65.     * @access private
  66.     */
  67.     var $handler_method_closing;
  68.     /**
  69.     * User defined object for handling data in elements
  70.     * @var object 
  71.     * @access private
  72.     */
  73.     var $handler_object_data;
  74.     /**
  75.     * User defined data handler method
  76.     * @var string 
  77.     * @access private
  78.     */
  79.     var $handler_method_data;
  80.     /**
  81.     * User defined object for handling processing instructions
  82.     * @var object 
  83.     * @access private
  84.     */
  85.     var $handler_object_pi;
  86.     /**
  87.     * User defined processing instruction handler method
  88.     * @var string 
  89.     * @access private
  90.     */
  91.     var $handler_method_pi;
  92.     /**
  93.     * User defined object for handling JSP/ASP tags
  94.     * @var object 
  95.     * @access private
  96.     */
  97.     var $handler_object_jasp;
  98.     /**
  99.     * User defined JSP/ASP handler method
  100.     * @var string 
  101.     * @access private
  102.     */
  103.     var $handler_method_jasp;
  104.     /**
  105.     * User defined object for handling XML escapes
  106.     * @var object 
  107.     * @access private
  108.     */
  109.     var $handler_object_escape;
  110.     /**
  111.     * User defined XML escape handler method
  112.     * @var string 
  113.     * @access private
  114.     */
  115.     var $handler_method_escape;
  116.     /**
  117.     * User defined handler object or NullHandler
  118.     * @var object 
  119.     * @access private
  120.     */
  121.     var $handler_default;
  122.     /**
  123.     * Parser options determining parsing behavior
  124.     * @var array 
  125.     * @access private
  126.     */
  127.     var $parser_options array();
  128.     /**
  129.     * XML document being parsed
  130.     * @var string 
  131.     * @access private
  132.     */
  133.     var $rawtext;
  134.     /**
  135.     * Position in XML document relative to start (0)
  136.     * @var int 
  137.     * @access private
  138.     */
  139.     var $position;
  140.     /**
  141.     * Length of the XML document in characters
  142.     * @var int 
  143.     * @access private
  144.     */
  145.     var $length;
  146.     /**
  147.     * Array of state objects
  148.     * @var array 
  149.     * @access private
  150.     */
  151.     var $State array();
  152.  
  153.     /**
  154.     * Constructs XML_HTMLSax3_StateParser setting up states
  155.     * @var XML_HTMLSax3 instance of user front end class
  156.     * @access protected
  157.     */
  158.     function XML_HTMLSax3_StateParser ($htmlsax{
  159.         $this->htmlsax $htmlsax;
  160.         $this->State[XML_HTMLSAX3_STATE_START=new XML_HTMLSax3_StartingState();
  161.  
  162.         $this->State[XML_HTMLSAX3_STATE_CLOSING_TAG=new XML_HTMLSax3_ClosingTagState();
  163.         $this->State[XML_HTMLSAX3_STATE_TAG=new XML_HTMLSax3_TagState();
  164.         $this->State[XML_HTMLSAX3_STATE_OPENING_TAG=new XML_HTMLSax3_OpeningTagState();
  165.  
  166.         $this->State[XML_HTMLSAX3_STATE_PI=new XML_HTMLSax3_PiState();
  167.         $this->State[XML_HTMLSAX3_STATE_JASP=new XML_HTMLSax3_JaspState();
  168.         $this->State[XML_HTMLSAX3_STATE_ESCAPE=new XML_HTMLSax3_EscapeState();
  169.     }
  170.  
  171.     /**
  172.     * Moves the position back one character
  173.     * @access protected
  174.     * @return void 
  175.     */
  176.     function unscanCharacter({
  177.         $this->position -= 1;
  178.     }
  179.  
  180.     /**
  181.     * Moves the position forward one character
  182.     * @access protected
  183.     * @return void 
  184.     */
  185.     function ignoreCharacter({
  186.         $this->position += 1;
  187.     }
  188.  
  189.     /**
  190.     * Returns the next character from the XML document or void if at end
  191.     * @access protected
  192.     * @return mixed 
  193.     */
  194.     function scanCharacter({
  195.         if ($this->position $this->length{
  196.             return $this->rawtext{$this->position++};
  197.         }
  198.     }
  199.  
  200.     /**
  201.     * Returns a string from the current position to the next occurance
  202.     * of the supplied string
  203.     * @param string string to search until
  204.     * @access protected
  205.     * @return string 
  206.     */
  207.     function scanUntilString($string{
  208.         $start $this->position;
  209.         $this->position strpos($this->rawtext$string$start);
  210.         if ($this->position === FALSE{
  211.             $this->position $this->length;
  212.         }
  213.         return substr($this->rawtext$start$this->position $start);
  214.     }
  215.  
  216.     /**
  217.     * Returns a string from the current position until the first instance of
  218.     * one of the characters in the supplied string argument
  219.     * @param string string to search until
  220.     * @access protected
  221.     * @return string 
  222.     * @abstract
  223.     */
  224.     function scanUntilCharacters($string{}
  225.  
  226.     /**
  227.     * Moves the position forward past any whitespace characters
  228.     * @access protected
  229.     * @return void 
  230.     * @abstract
  231.     */
  232.     function ignoreWhitespace({}
  233.  
  234.     /**
  235.     * Begins the parsing operation, setting up any decorators, depending on
  236.     * parse options invoking _parse() to execute parsing
  237.     * @param string XML document to parse
  238.     * @access protected
  239.     * @return void 
  240.     */
  241.     function parse($data{
  242.         if ($this->parser_options['XML_OPTION_TRIM_DATA_NODES']==1{
  243.             $decorator =new XML_HTMLSax3_Trim(
  244.                 $this->handler_object_data,
  245.                 $this->handler_method_data);
  246.             $this->handler_object_data =$decorator;
  247.             $this->handler_method_data 'trimData';
  248.         }
  249.         if ($this->parser_options['XML_OPTION_CASE_FOLDING']==1{
  250.             $open_decor =new XML_HTMLSax3_CaseFolding(
  251.                 $this->handler_object_element,
  252.                 $this->handler_method_opening,
  253.                 $this->handler_method_closing);
  254.             $this->handler_object_element =$open_decor;
  255.             $this->handler_method_opening ='foldOpen';
  256.             $this->handler_method_closing ='foldClose';
  257.         }
  258.         if ($this->parser_options['XML_OPTION_LINEFEED_BREAK']==1{
  259.             $decorator =new XML_HTMLSax3_Linefeed(
  260.                 $this->handler_object_data,
  261.                 $this->handler_method_data);
  262.             $this->handler_object_data =$decorator;
  263.             $this->handler_method_data 'breakData';
  264.         }
  265.         if ($this->parser_options['XML_OPTION_TAB_BREAK']==1{
  266.             $decorator =new XML_HTMLSax3_Tab(
  267.                 $this->handler_object_data,
  268.                 $this->handler_method_data);
  269.             $this->handler_object_data =$decorator;
  270.             $this->handler_method_data 'breakData';
  271.         }
  272.         if ($this->parser_options['XML_OPTION_ENTITIES_UNPARSED']==1{
  273.             $decorator =new XML_HTMLSax3_Entities_Unparsed(
  274.                 $this->handler_object_data,
  275.                 $this->handler_method_data);
  276.             $this->handler_object_data =$decorator;
  277.             $this->handler_method_data 'breakData';
  278.         }
  279.         if ($this->parser_options['XML_OPTION_ENTITIES_PARSED']==1{
  280.             $decorator =new XML_HTMLSax3_Entities_Parsed(
  281.                 $this->handler_object_data,
  282.                 $this->handler_method_data);
  283.             $this->handler_object_data =$decorator;
  284.             $this->handler_method_data 'breakData';
  285.         }
  286.         // Note switched on by default
  287.         if ($this->parser_options['XML_OPTION_STRIP_ESCAPES']==1{
  288.             $decorator =new XML_HTMLSax3_Escape_Stripper(
  289.                 $this->handler_object_escape,
  290.                 $this->handler_method_escape);
  291.             $this->handler_object_escape =$decorator;
  292.             $this->handler_method_escape 'strip';
  293.         }
  294.         $this->rawtext $data;
  295.         $this->length strlen($data);
  296.         $this->position 0;
  297.         $this->_parse();
  298.     }
  299.  
  300.     /**
  301.     * Performs the parsing itself, delegating calls to a specific parser
  302.     * state
  303.     * @param constant state object to parse with
  304.     * @access protected
  305.     * @return void 
  306.     */
  307.     function _parse($state XML_HTMLSAX3_STATE_START{
  308.         do {
  309.             $state $this->State[$state]->parse($this);
  310.         while ($state != XML_HTMLSAX3_STATE_STOP &&
  311.                     $this->position $this->length);
  312.     }
  313. }
  314.  
  315. /**
  316. * Parser for PHP Versions below 4.3.0. Uses a slower parsing mechanism than
  317. * the equivalent PHP 4.3.0+  subclass of StateParser
  318. @package XML_HTMLSax3
  319. @access protected
  320. @see XML_HTMLSax3_StateParser_Gtet430
  321. */
  322.     /**
  323.     * Constructs XML_HTMLSax3_StateParser_Lt430 defining available
  324.     * parser options
  325.     * @var XML_HTMLSax3 instance of user front end class
  326.     * @access protected
  327.     */
  328.     function XML_HTMLSax3_StateParser_Lt430($htmlsax{
  329.         parent::XML_HTMLSax3_StateParser($htmlsax);
  330.         $this->parser_options['XML_OPTION_TRIM_DATA_NODES'0;
  331.         $this->parser_options['XML_OPTION_CASE_FOLDING'0;
  332.         $this->parser_options['XML_OPTION_LINEFEED_BREAK'0;
  333.         $this->parser_options['XML_OPTION_TAB_BREAK'0;
  334.         $this->parser_options['XML_OPTION_ENTITIES_PARSED'0;
  335.         $this->parser_options['XML_OPTION_ENTITIES_UNPARSED'0;
  336.         $this->parser_options['XML_OPTION_STRIP_ESCAPES'0;
  337.     }
  338.  
  339.     /**
  340.     * Returns a string from the current position until the first instance of
  341.     * one of the characters in the supplied string argument
  342.     * @param string string to search until
  343.     * @access protected
  344.     * @return string 
  345.     */
  346.     function scanUntilCharacters($string{
  347.         $startpos $this->position;
  348.         while ($this->position $this->length && strpos($string$this->rawtext{$this->position}=== FALSE{
  349.             $this->position++;
  350.         }
  351.         return substr($this->rawtext$startpos$this->position $startpos);
  352.     }
  353.  
  354.     /**
  355.     * Moves the position forward past any whitespace characters
  356.     * @access protected
  357.     * @return void 
  358.     */
  359.     function ignoreWhitespace({
  360.         while ($this->position $this->length &&
  361.             strpos(" \n\r\t"$this->rawtext{$this->position}!== FALSE{
  362.             $this->position++;
  363.         }
  364.     }
  365.  
  366.     /**
  367.     * Begins the parsing operation, setting up the unparsed XML entities
  368.     * decorator if necessary then delegating further work to parent
  369.     * @param string XML document to parse
  370.     * @access protected
  371.     * @return void 
  372.     */
  373.     function parse($data{
  374.         parent::parse($data);
  375.     }
  376. }
  377.  
  378. /**
  379. * Parser for PHP Versions equal to or greater than 4.3.0. Uses a faster
  380. * parsing mechanism than the equivalent PHP < 4.3.0 subclass of StateParser
  381. @package XML_HTMLSax3
  382. @access protected
  383. @see XML_HTMLSax3_StateParser_Lt430
  384. */
  385.     /**
  386.     * Constructs XML_HTMLSax3_StateParser_Gtet430 defining available
  387.     * parser options
  388.     * @var XML_HTMLSax3 instance of user front end class
  389.     * @access protected
  390.     */
  391.     function XML_HTMLSax3_StateParser_Gtet430($htmlsax{
  392.         parent::XML_HTMLSax3_StateParser($htmlsax);
  393.         $this->parser_options['XML_OPTION_TRIM_DATA_NODES'0;
  394.         $this->parser_options['XML_OPTION_CASE_FOLDING'0;
  395.         $this->parser_options['XML_OPTION_LINEFEED_BREAK'0;
  396.         $this->parser_options['XML_OPTION_TAB_BREAK'0;
  397.         $this->parser_options['XML_OPTION_ENTITIES_PARSED'0;
  398.         $this->parser_options['XML_OPTION_ENTITIES_UNPARSED'0;
  399.         $this->parser_options['XML_OPTION_STRIP_ESCAPES'0;
  400.     }
  401.     /**
  402.     * Returns a string from the current position until the first instance of
  403.     * one of the characters in the supplied string argument.
  404.     * @param string string to search until
  405.     * @access protected
  406.     * @return string 
  407.     */
  408.     function scanUntilCharacters($string{
  409.         $startpos $this->position;
  410.         $length strcspn($this->rawtext$string$startpos);
  411.         $this->position += $length;
  412.         return substr($this->rawtext$startpos$length);
  413.     }
  414.  
  415.     /**
  416.     * Moves the position forward past any whitespace characters
  417.     * @access protected
  418.     * @return void 
  419.     */
  420.     function ignoreWhitespace({
  421.         $this->position += strspn($this->rawtext" \n\r\t"$this->position);
  422.     }
  423.  
  424.     /**
  425.     * Begins the parsing operation, setting up the parsed and unparsed
  426.     * XML entity decorators if necessary then delegating further work
  427.     * to parent
  428.     * @param string XML document to parse
  429.     * @access protected
  430.     * @return void 
  431.     */
  432.     function parse($data{
  433.         parent::parse($data);
  434.     }
  435. }
  436.  
  437. /**
  438. * Default NullHandler for methods which were not set by user
  439. @package XML_HTMLSax3
  440. @access protected
  441. */
  442.     /**
  443.     * Generic handler method which does nothing
  444.     * @access protected
  445.     * @return void 
  446.     */
  447.     function DoNothing({
  448.     }
  449. }
  450.  
  451. /**
  452. * User interface class. All user calls should only be made to this class
  453. @package XML_HTMLSax3
  454. @access public
  455. */
  456. class XML_HTMLSax3 {
  457.     /**
  458.     * Instance of concrete subclass of XML_HTMLSax3_StateParser
  459.     * @var XML_HTMLSax3_StateParser 
  460.     * @access private
  461.     */
  462.     var $state_parser;
  463.  
  464.     /**
  465.     * Constructs XML_HTMLSax3 selecting concrete StateParser subclass
  466.     * depending on PHP version being used as well as setting the default
  467.     * NullHandler for all callbacks<br />
  468.     * <b>Example:</b>
  469.     * <pre>
  470.     * $myHandler = & new MyHandler();
  471.     * $parser = new XML_HTMLSax3();
  472.     * $parser->set_object($myHandler);
  473.     * $parser->set_option('XML_OPTION_CASE_FOLDING');
  474.     * $parser->set_element_handler('myOpenHandler','myCloseHandler');
  475.     * $parser->set_data_handler('myDataHandler');
  476.     * $parser->parser($xml);
  477.     * </pre>
  478.     * @access public
  479.     */
  480.     function XML_HTMLSax3({
  481.         if (version_compare(phpversion()'4.3''ge')) {
  482.             $this->state_parser =new XML_HTMLSax3_StateParser_Gtet430($this);
  483.         else {
  484.             $this->state_parser =new XML_HTMLSax3_StateParser_Lt430($this);
  485.         }
  486.         $nullhandler =new XML_HTMLSax3_NullHandler();
  487.         $this->set_object($nullhandler);
  488.         $this->set_element_handler('DoNothing''DoNothing');
  489.         $this->set_data_handler('DoNothing');
  490.         $this->set_pi_handler('DoNothing');
  491.         $this->set_jasp_handler('DoNothing');
  492.         $this->set_escape_handler('DoNothing');
  493.     }
  494.  
  495.     /**
  496.     * Sets the user defined handler object. Returns a PEAR Error
  497.     * if supplied argument is not an object.
  498.     * @param object handler object containing SAX callback methods
  499.     * @access public
  500.     * @return mixed 
  501.     */
  502.     function set_object(&$object{
  503.         if is_object($object) ) {
  504.             $this->state_parser->handler_default =$object;
  505.             return true;
  506.         else {
  507.             Loader::requireOnce('PEAR.php');
  508.             PEAR::raiseError('XML_HTMLSax3::set_object requires '.
  509.                 'an object instance');
  510.         }
  511.     }
  512.  
  513.     /**
  514.     * Sets a parser option. By default all options are switched off.
  515.     * Returns a PEAR Error if option is invalid<br />
  516.     * <b>Available options:</b>
  517.     * <ul>
  518.     * <li>XML_OPTION_TRIM_DATA_NODES: trim whitespace off the beginning
  519.     * and end of data passed to the data handler</li>
  520.     * <li>XML_OPTION_LINEFEED_BREAK: linefeeds result in additional data
  521.     * handler calls</li>
  522.     * <li>XML_OPTION_TAB_BREAK: tabs result in additional data handler
  523.     * calls</li>
  524.     * <li>XML_OPTION_ENTITIES_UNPARSED: XML entities are returned as
  525.     * seperate data handler calls in unparsed form</li>
  526.     * <li>XML_OPTION_ENTITIES_PARSED: (PHP 4.3.0+ only) XML entities are
  527.     * returned as seperate data handler calls and are parsed with
  528.     * PHP's html_entity_decode() function</li>
  529.     * <li>XML_OPTION_STRIP_ESCAPES: strips out the -- -- comment markers
  530.     * or CDATA markup inside an XML escape, if found.</li>
  531.     * </ul>
  532.     * To get HTMLSax to behave in the same way as the native PHP SAX parser,
  533.     * using it's default state, you need to switch on XML_OPTION_LINEFEED_BREAK,
  534.     * XML_OPTION_ENTITIES_PARSED and XML_OPTION_CASE_FOLDING
  535.     * @param string name of parser option
  536.     * @param int (optional) 1 to switch on, 0 for off
  537.     * @access public
  538.     * @return boolean 
  539.     */
  540.     function set_option($name$value=1{
  541.         if array_key_exists($name,$this->state_parser->parser_options) ) {
  542.             $this->state_parser->parser_options[$name$value;
  543.             return true;
  544.         else {
  545.             Loader::requireOnce('PEAR.php');
  546.             PEAR::raiseError('XML_HTMLSax3::set_option('.$name.') illegal');
  547.         }
  548.     }
  549.  
  550.     /**
  551.     * Sets the data handler method which deals with the contents of XML
  552.     * elements.<br />
  553.     * The handler method must accept two arguments, the first being an
  554.     * instance of XML_HTMLSax3 and the second being the contents of an
  555.     * XML element e.g.
  556.     * <pre>
  557.     * function myDataHander(& $parser,$data){}
  558.     * </pre>
  559.     * @param string name of method
  560.     * @access public
  561.     * @return void 
  562.     * @see set_object
  563.     */
  564.     function set_data_handler($data_method{
  565.         $this->state_parser->handler_object_data =$this->state_parser->handler_default;
  566.         $this->state_parser->handler_method_data $data_method;
  567.     }
  568.  
  569.     /**
  570.     * Sets the open and close tag handlers
  571.     * <br />The open handler method must accept three arguments; the parser,
  572.     * the tag name and an array of attributes e.g.
  573.     * <pre>
  574.     * function myOpenHander(& $parser,$tagname,$attrs=array()){}
  575.     * </pre>
  576.     * The close handler method must accept two arguments; the parser and
  577.     * the tag name e.g.
  578.     * <pre>
  579.     * function myCloseHander(& $parser,$tagname){}
  580.     * </pre>
  581.     * @param string name of open method
  582.     * @param string name of close method
  583.     * @access public
  584.     * @return void 
  585.     * @see set_object
  586.     */
  587.     function set_element_handler($opening_method$closing_method{
  588.         $this->state_parser->handler_object_element =$this->state_parser->handler_default;
  589.         $this->state_parser->handler_method_opening $opening_method;
  590.         $this->state_parser->handler_method_closing $closing_method;
  591.     }
  592.  
  593.     /**
  594.     * Sets the processing instruction handler method e.g. for PHP open
  595.     * and close tags<br />
  596.     * The handler method must accept three arguments; the parser, the
  597.     * PI target and data inside the PI
  598.     * <pre>
  599.     * function myPIHander(& $parser,$target, $data){}
  600.     * </pre>
  601.     * @param string name of method
  602.     * @access public
  603.     * @return void 
  604.     * @see set_object
  605.     */
  606.     function set_pi_handler($pi_method{
  607.         $this->state_parser->handler_object_pi =$this->state_parser->handler_default;
  608.         $this->state_parser->handler_method_pi $pi_method;
  609.     }
  610.  
  611.     /**
  612.     * Sets the XML escape handler method e.g. for comments and doctype
  613.     * declarations<br />
  614.     * The handler method must accept two arguments; the parser and the
  615.     * contents of the escaped section
  616.     * <pre>
  617.     * function myEscapeHander(& $parser, $data){}
  618.     * </pre>
  619.     * @param string name of method
  620.     * @access public
  621.     * @return void 
  622.     * @see set_object
  623.     */
  624.     function set_escape_handler($escape_method{
  625.         $this->state_parser->handler_object_escape =$this->state_parser->handler_default;
  626.         $this->state_parser->handler_method_escape $escape_method;
  627.     }
  628.  
  629.     /**
  630.     * Sets the JSP/ASP markup handler<br />
  631.     * The handler method must accept two arguments; the parser and
  632.     * body of the JASP tag
  633.     * <pre>
  634.     * function myJaspHander(& $parser, $data){}
  635.     * </pre>
  636.     * @param string name of method
  637.     * @access public
  638.     * @return void 
  639.     * @see set_object
  640.     */
  641.     function set_jasp_handler ($jasp_method{
  642.         $this->state_parser->handler_object_jasp =$this->state_parser->handler_default;
  643.         $this->state_parser->handler_method_jasp $jasp_method;
  644.     }
  645.  
  646.     /**
  647.     * Returns the current string position of the "cursor" inside the XML
  648.     * document
  649.     * <br />Intended for use from within a user defined handler called
  650.     * via the $parser reference e.g.
  651.     * <pre>
  652.     * function myDataHandler(& $parser,$data) {
  653.     *     echo( 'Current position: '.$parser->get_current_position() );
  654.     * }
  655.     * </pre>
  656.     * @access public
  657.     * @return int 
  658.     * @see get_length
  659.     */
  660.     function get_current_position({
  661.         return $this->state_parser->position;
  662.     }
  663.  
  664.     /**
  665.     * Returns the string length of the XML document being parsed
  666.     * @access public
  667.     * @return int 
  668.     */
  669.     function get_length({
  670.         return $this->state_parser->length;
  671.     }
  672.  
  673.     /**
  674.     * Start parsing some XML
  675.     * @param string XML document
  676.     * @access public
  677.     * @return void 
  678.     */
  679.     function parse($data{
  680.         $this->state_parser->parse($data);
  681.     }
  682. }

Documentation generated on Fri, 18 Jul 2008 21:46:34 +0200 by phpDocumentor 1.4.1