note 83242 deleted from class.xmlreader by thiago
| From: | thiago@php.net | Date: | Wed, 12 Nov 2008 13:35:48 +0000 |
| Subject: | note 83242 deleted from class.xmlreader by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146428@lists.php.net to get a copy of this message | ||
Note Submitter: WebSee.Ru
----
Next version xml2assoc (real assoc):
function xml2assoc(&$xml) {
$assoc = NULL;
while($xml->read()){
switch ($xml->nodeType) {
case XMLReader::END_ELEMENT: return $assoc;
case XMLReader::ELEMENT:
$atr = array();
if($xml->hasAttributes) while($xml->moveToNextAttribute()) $atr[$xml->name] =
$xml->value;
$assoc[$xml->name][] = array('name' => $xml->name, 'attributes'
=> $atr, 'value' => $xml->isEmptyElement ? '' : xml2assoc($xml));
break;
case XMLReader::TEXT:
case XMLReader::CDATA: $assoc .= $xml->value;
}
}
return $assoc;
}