示例#1
0
        if (is_null($this->last)) {
            $this->root =& $node;
        } else {
            $this->last->addChild(&$node);
        }
        $this->last =& $node;
    }
    function end($parser, $name)
    {
        $this->last =& $this->last->parent;
    }
    function cdata($parser, $data)
    {
        if (!is_null($this->last)) {
            $this->last->setContent(trim($data));
        }
    }
    function &getRoot()
    {
        return $this->root;
    }
}
$xml_file = 'presentations/slides/sdphp/data/sdphp_talk2.xml';
$xmldoc = implode('', file($xml_file));
$parser = new XMLParser();
$parser->parse($xmldoc);
$root = $parser->getRoot();
echo "<pre>\n" . $root->toString() . "</pre>\n";
?>