I hadn't noticed that. My php.ini was set to on, changing it to off gave the
warning.
Having changed:
xml_set_object($this->parser,&$this);
to:
xml_set_object($this->parser,$this);
Stops the warning and the parser works fine.

This is the class I'm using and it works fine:

class parse_words_xml  {
 var $words;

 function parse_words_xml($xml_data) {
     $this->words = array();
     $this->parser = xml_parser_create();
     xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
     xml_set_element_handler($this->parser,"tag_open","tag_close");
     xml_set_character_data_handler($this->parser,"cdata");
     $this->parse($xml_data);
 }

 function parse($xml_data) {
      xml_set_object($this->parser,$this);
      reset ($xml_data);
      while (list (, $data) = each ($xml_data)) {
      if (!xml_parse($this->parser, $data)) {
          die(sprintf( "XML error: %s at line %d\n\n",
          xml_error_string(xml_get_error_code($this->parser)),
          xml_get_current_line_number($this->parser)));
      }
  }

 }

 function tag_open($parser,$tag,$attributes) {
     $this->current_tag = $tag;
     switch($tag){
     case 'Word':
            $this->id = $attributes['id'];
            $this->words[$attributes['id']] = 1;
         break;
     default:
         break;
     }
 }

 function cdata($parser,$cdata) {
  $this->temp = $cdata;
 }

 function tag_close($parser,$tag) {
     switch($tag){
     case 'Word':
            $this->words[$this->id] = $this->temp;
            $this->temp = '';
         break;
     default:
         break;
     }
 }

}


"Clay Loveless" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Unfortunately, the xml_set_object function does not work to solve this
> problem. I tried using it, and my results were the same as they were when
I
> was not using it.
>
> [I found that the array($this, 'function_name') method instead of 'string
> function_name' for the xml_set_*_handler functions worked just as well,
only
> without this Warning message one gets from PHP 4.2.1 upon using
> xml_set_object($this->parser, &$this):
>
> "PHP Warning:  Call-time pass-by-reference has been deprecated - argument
> passed by value;  If you would like to pass it by reference, modify the
> declaration of xml_set_object().  If you would like to enable call-time
> pass-by-reference, you can set allow_call_time_pass_reference to true in
> your INI file.  However, future versions may not support this any
longer."]
>
>
> Still searching for an answer on this one ...
>
> Thanks,
> -Clay
>
>
>
> > "Peter Clarke" <[EMAIL PROTECTED]>
> >
> > Have a look at:
> > http://www.php.net/manual/en/function.xml-set-object.php
> >
> > xml_set_object($this->parser, &$this);
> >
> >
> >
> > "Clay Loveless" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> >> Here's a brain-bender ... At least it is for me at the moment. : )
> >>
> >> When I use an XML parser inside a class, the xml_*_handler functions
> > aren't
> >> recognizing "$this->" variables. I can kind of see why ... But would
like
> > it
> >> to work anyway. : )
> >>
> >> Here's an example:
> >>
> >> class Blah
> >> {
> >>     var $xmlparser;
> >>     var $current_element;
> >>
> >>     // ...
> >>
> >>     function _parseXML($data)
> >>     {
> >>         $this->xmlparser = xml_parser_create();
> >>         xml_set_element_handler(
> >>             $this->xmlparser,
> >>             array($this,"_xml_start_element"),
> >>             array($this,"_xml_end_element"));
> >>         xml_set_character_data_handler(
> >>             $this->xmlparser,
> >>             array($this,"_xml_character_data"));
> >>         xml_parse($this->xmlparser, $data);
> >>         xml_parser_free($this->xmlparser);
> >>     }
> >>
> >>     function _xml_start_element($p, $e_name, $e_attributes)
> >>     {
> >>             $this->current_element = $e_name;
> >>     }
> >>
> >>     function _xml_end_element($p, $e_name)
> >>     {
> >>             // ...
> >>     }
> >>
> >>     function _xml_character_data($p, $data)
> >>     {
> >>         echo "element is: ".$this->current_element."\n";
> >>         echo "data is: $data\n";
> >>     }
> >>
> >> } // end of class Blah
> >>
> >>
> >>
> >> When this XML parser gets called from within the Blah class, the
"element
> >> is:" portion of _xml_character_data comes out blank!
> >>
> >> This sort of makes sense, because the callback functions are "children"
of
> >> the xml_parser_create "parent" ... But should that make the children
> >> ignorant of the "grandparent" variables referred to by $this->varname?
> >>
> >> I hope this makes sense ... Has anyone else encountered this sort of
> >> problem? I'm an old hat at PHP, but am relatively new to both XML
parsing
> >> and writing my own classes.
> >>
> >> Thanks,
> >> Clay
> >>
> >
> >
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to