On Wed, Jul 03, 2002 at 11:05:34AM -0700, Clay Loveless wrote:
> "Note: Instead of a function name, an array containing an object reference
> and a method name can also be supplied."

Interesting.  Thanks!

Anyway, back to your situation.  I put together a test.  Two counters are
running and get displayed each time each function is called.  One counter
is a regular variable which I bring into each function via a global
statement.  The other counter is part of the object.

Interestingly, in this case, the object variables are not acting as if
they are part of the class, rather they're behaving as if their scope is
stuck within each function.

As far as parsing XML, be aware that the character data handler get's
called for each bit of non-tag data, including white spaces in tags and
between tags.  And, character data can contain multiple lines but they get
passed through the character data handler function one line at a time, not
all at once.  So, performing maneuvers in the character_handler function
is tricky.  I save my character data in an array and then implode the
array in the end handler function.  This process is in the test, below, as

I've got a PHP XML expat parsing tutorial up on the web that may prove 

#! /usr/local/bin/php -q

class Blah
    var $xmlparser;
    var $current_element;
    var $count = 0;

    function _parseXML($data)
        global $g;
        $g = 0;

        $this->xmlparser = xml_parser_create();
        xml_parse($this->xmlparser, $data);

    function _xml_start_element($p, $e_name, $e_attributes)
       global $CData, $g;
       $CData = array();
       echo 'g:' . ++$g . ' o:' . ++$this->count . " start\n";
       echo "  start element: $e_name\n";

    function _xml_character_data($p, $data)
       global $CData, $g;
       $CData[] = $data;
       echo 'g:' . ++$g . ' o:' . ++$this->count . " character\n";
       echo "  character data: $data\n";

    function _xml_end_element($p, $e_name)
       global $CData, $g;
       echo 'g:' . ++$g . ' o:' . ++$this->count . " end\n";
       echo "  end element: $e_name\n";
       echo "  end data array: " . trim( implode('', $CData) ) . "\n";

} // end of class Blah

$XML = '
  Some Item Text

echo "$XML\n";

$Class = new Blah();




               PHP classes that make web design easier
        SQL Solution  |   Layout Solution   |  Form Solution  | |
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY     v: 718-854-0335     f: 718-854-0409

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to