XML_Parser and php
| From: | Robin Ericsson | Date: | Wed, 20 Nov 2002 08:54:59 +0000 |
| Subject: | XML_Parser and php | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-91340@lists.php.net to get a copy of this message | ||
Is there any known problems with php 4.2.3 and the latest pear
xml_parser?
I have a class that extends XML_Parser, and I have several problems.
One problem is that variables is emptied without notice, and another
problem that is that memory seems to be overwridden.
I've attached my local functions, and this is the like that causes the
problem:
$this->aCurrentProduct["category"] .= $data."/";
The right category should be:
DATORKOMPONENTER/MINNEN/VIKING COMPONENTS/
but I see things like this:
DATORKOMPON/ENTER/MINNEN/VIKING COMPONENTS/
DATORKOMPONENTER/MINNE/N/VIKING COMPONENTS/
DATORKOMPONE/NTER/MINNEN/VIKING COMPONENTS/
DATORKOMPONENTER/M/INNEN/VIKING COMPONENTS/
DATOR/KOMPONENTER/MINNEN/VIKING COMPONENTS/
DATORKOMPONENTER/MINNEN/VIKIN/G COMPONENTS/
DATORKOMPONEN/TER/MINNEN/VIKING COMPONENTS/
DATORKOMPONENT/ER/MINNEN/VIKING COMPONENTS/
DATO/RKOMPONENTER/MINNEN/VIKING COMPONENTS/
DATORKOMPONENTE/R/MINNEN/VIKING COMPONENTS/
DATORKOM/PONENTER/MINNEN/VIKING COMPONENTS/
--
Robin Ericsson <lobbin@localhost.nu>
function cDataHandler($xp, $data) { switch($this->sCurrentNode) { case "PARTNUMBER": $use = "anr"; break; case "DESCRIPTION": $use = "name"; break; case "PRICEWITHTAX": $use = "price"; break; case "MANUFACTURER": $use = "manufacturer"; break; case "MANUF_PARTNUMBER": $use = "manufacturer.anr"; break; case "PRODUCTURL": $use = "product.url"; break; } if ($use != "") { $this->aCurrentProduct[$use] = $data; } if (stristr($this->sCurrentNode, "PRODUCTGROUP_") && $data != "") { $this->aCurrentProduct["category"] .= $data."/"; } } function StartHandler($xp, $elem, &$attribs) { $this->sCurrentNode = $elem; } function EndHandler($xp, $elem) { global $tempProducts; if ($elem == "ITEMADD") { $this->aCurrentProduct["category"] = $this->translateCategory($this->aCurrentProduct["category"]); $tempProducts[] = $this->aCurrentProduct; $this->aCurrentProduct = array(); } $this->sCurrentNode = ""; }
function cDataHandler($xp, $data) { switch($this->sCurrentNode) { case "PARTNUMBER": $use = "anr"; break; case "DESCRIPTION": $use = "name"; break; case "PRICEWITHTAX": $use = "price"; break; case "MANUFACTURER": $use = "manufacturer"; break; case "MANUF_PARTNUMBER": $use = "manufacturer.anr"; break; case "PRODUCTURL": $use = "product.url"; break; } if ($use != "") { $this->aCurrentProduct[$use] = $data; } if (stristr($this->sCurrentNode, "PRODUCTGROUP_") && $data != "") { $this->aCurrentProduct["category"] .= $data."/"; } } function StartHandler($xp, $elem, &$attribs) { $this->sCurrentNode = $elem; } function EndHandler($xp, $elem) { global $tempProducts; if ($elem == "ITEMADD") { $this->aCurrentProduct["category"] = $this->translateCategory($this->aCurrentProduct["category"]); $tempProducts[] = $this->aCurrentProduct; $this->aCurrentProduct = array(); } $this->sCurrentNode = ""; }