note 83574 deleted from class.xmlreader by thiago
| From: | thiago@php.net | Date: | Wed, 12 Nov 2008 13:36:28 +0000 |
| Subject: | note 83574 deleted from class.xmlreader by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146430@lists.php.net to get a copy of this message | ||
Note Submitter: robbiemcelrath AT hotmail DOT com
----
Fixes a bug in WebSee.Ru's xml2assoc function:
function xml2assoc($xml) {
$assoc = null;
while($xml->read()){
switch ($xml->nodeType) {
case XMLReader::END_ELEMENT: return $assoc;
case XMLReader::ELEMENT:
$name = $xml->name;
$atr = array();
if($xml->hasAttributes) while($xml->moveToNextAttribute()) $atr[$xml->name]
= $xml->value;
$assoc[$name][] = array('name' => $name, 'attributes' =>
$atr, 'value' => $xml->isEmptyElement ? '' : xml2assoc($xml));
break;
case XMLReader::TEXT:
case XMLReader::CDATA: $assoc .= $xml->value;
}
}
return $assoc;
}