problem with XML_Parser
| From: | Filippo Veneri | Date: | Thu, 12 Dec 2002 09:17:20 +0000 |
| Subject: | problem with XML_Parser | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-2951@lists.php.net to get a copy of this message | ||
The following peace of code does not work as expected:
<?php
require_once "XML/Parser.php";
class MyParser extends XML_Parser {
var $variable = null;
function startHandler($xp, $name, &$attribs)
{
if ($name == "TAG") {
$this->variable = "I am a beautyful string";
echo $this->variable . "\n";
}
}
function endHandler($xp, $name)
{
}
function doParse($file)
{
$this->setInputFile($file);
$this->parse();
echo $this->variable . "\n";
}
}
$mp = new MyParser();
$mp->doParse("tag.xml");
?>
given a very simple input XML file with the following content:
<tag />
the above script prints "I am a beautyful string" once only, instead of
twice.
Can someone explain me why?
Thanks,
fbv