Hi,
I'm new to this list, and was forced to join because of following
problem, BTW searching through the archive ended without any useable
results. The problem is in following code - which is little extended
source from example in manual entry for xml_set_object() function. I've
added one member variable called result and there I'm storing everything
what is parsed through parser - I want to have control over what is
parsed - then, when I wanted to show the result - variable was empty,
but when u'll uncomments line in tag_open() function, will see
interesting results - var. is being updated.
Where is mistake?
Mirek Novak
----------------------------------------- PHP code follows
------------------------------------
<?
class xml {
var $parser;
var $result;
function xml() {
$this->parser = xml_parser_create();
$this->result="<br><u>result</u><br>";
xml_set_object($this->parser,&$this);
xml_set_element_handler($this->parser,"tag_open","tag_close");
xml_set_character_data_handler($this->parser,"cdata");
}
function parse($data) {
xml_parse($this->parser,$data);
}
function tag_open($parser,$tag,$attributes) {
var_dump($parser,$tag,$attributes);
$this->result.="TAG: ".$tag."<br>";
// if u uncomment line below, U'll see, that $this->result really
contains what it shoud
// echo $this->result;
}
function cdata($parser,$cdata) {
var_dump($parser,$cdata);
$this->result.="DATA: ".$cdata."<br>";
}
function tag_close($parser,$tag) {
var_dump($parser,$tag);
}
}
$xml_parser = new xml();
$xml_parser->parse("<A ID=\"hallo\">PHP</A>");
echo $xml_parser->result;
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]