note 81852 added to ref.xmlreader

From: Date: Sun, 16 Mar 2008 18:03:42 +0000
Subject: note 81852 added to ref.xmlreader
Groups: php.notes 
Request: Send a blank email to php-notes+get-137105@lists.php.net to get a copy of this message
make some modify from Sergey Aikinkulov's note function xml2assoc(&$xml){ $assoc = NULL; $n = 0; while($xml->read()){ if($xml->nodeType == XMLReader::END_ELEMENT) break; if($xml->nodeType == XMLReader::ELEMENT and !$xml->isEmptyElement){ $assoc[$n]['name'] = $xml->name; if($xml->hasAttributes) while($xml->moveToNextAttribute()) $assoc[$n]['atr'][$xml->name] = $xml->value; $assoc[$n]['val'] = xml2assoc($xml); $n++; } else if($xml->isEmptyElement){ $assoc[$n]['name'] = $xml->name; if($xml->hasAttributes) while($xml->moveToNextAttribute()) $assoc[$n]['atr'][$xml->name] = $xml->value; $assoc[$n]['val'] = ""; $n++; } else if($xml->nodeType == XMLReader::TEXT) $assoc = $xml->value; } return $assoc; } add else if($xml->isEmptyElement) may be some xml has emptyelement ---- Server IP: 140.113.54.119 Probable Submitter: 118.171.235.188 ---- Manual Page -- http://www.php.net/manual/en/ref.xmlreader.php Edit -- https://master.php.net/note/edit/81852 Del: integrated -- https://master.php.net/note/delete/81852/integrated Del: useless -- https://master.php.net/note/delete/81852/useless Del: bad code -- https://master.php.net/note/delete/81852/bad+code Del: spam -- https://master.php.net/note/delete/81852/spam Del: non-english -- https://master.php.net/note/delete/81852/non-english Del: in docs -- https://master.php.net/note/delete/81852/in+docs Del: other reasons-- https://master.php.net/note/delete/81852 Reject -- https://master.php.net/note/reject/81852 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#137105) next »