Re: AW: [PEAR-DEV] PACKAGE PROPOSAL: XML_XMLPull
| From: | Tomas V.V.Cox | Date: | Sat, 13 Sep 2003 16:11:22 +0000 |
| Subject: | Re: AW: [PEAR-DEV] PACKAGE PROPOSAL: XML_XMLPull | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-21474@lists.php.net to get a copy of this message | ||
On Saturday, September 13, 2003 12:51, Stephan Schmidt wrote:
> Hi,
> Harry, basically I like the idea very much (I already took a look at it
> on your site), but I also agree with Tomas, that it can be done in a few
> lines by extending XML_Parser.
>> This stuff can be implemented in less than 30 lines of code extending
> XML_Parser.
>> If you people fell that pull "style" parsing is interesting,
>> I'd provide it as addon of XML_Parser but not as a bloated separate
> package IMHO.
> If I can manage to free some time, I'll do a sample implementation this
> weekend by extending XML_Parser. I think it shouldn't be hard to create
> simple implementations of this in XML_Parser and XML_HTMLSax...
class XML_Pull extends XML_Parser {
var $stack = array();
var $i = 0;
function &parse() {
return @$this->stack[++$this->i];
}
function startHandler($xp, $elem, $att) {
$this->stack[] = new XML_Pull_Event(START, $elem, $att);
}
function endHandler($xp, $elem) {
$this->stack[] = new XML_Pull_Event(END, $elem);
}
function cdataHandler($xp, $data) {
$this->stack[] = new XML_Pull_Event(TEXT, $data);
}
}
class XML_Pull_Event {
function XML_Pull_Event($type, $param1, $param2 = null) {
$this->type = $type;
$this->param1 = $param1;
$this->param2 = $param2;
}
function getType() {
return $this->type;
}
function getElem() {
return $this->param1;
}
function getAttributes() {
return $this->param2;
}
function getText() {
return $this->param1;
}
}
>> It even provides not related stuff like var streaming while we already
> have a package for it.
> This stuff seems to be included in XML_SaxFilters, so it's already in
> PEAR...
I was reffering to the Stream_Var package.
--
Tomas V.V.Cox mailto:cox@idecnet.com