note 99009 deleted from class.xmlreader by danbrown

From: Date: Wed, 21 Jul 2010 22:06:43 +0000
Subject: note 99009 deleted from class.xmlreader by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-171031@lists.php.net to get a copy of this message
Note Submitter: tolga dot akardeniz at hotmail dot com ---- function xml_read($xml_file){ $xml = new XMLReader(); $xml->open($xml_file); $xml_array = NULL; $xml_protection = NULL; $n = 0; while($xml->read()){ if($xml->nodeType == XMLReader::END_ELEMENT) { $n++; $xml->moveToElement(); } if($xml->nodeType == XMLReader::ELEMENT and !$xml->isEmptyElement){ if (!$xml_protection[$n]) { $xml_protection[$n] = 1; } else { $n++; } $xml_array[$n]['name'] = $xml->name; if($xml->hasAttributes) while($xml->moveToNextAttribute()) $xml_array[$n]['attribute'][$xml->name] = $xml->value; } else if($xml->isEmptyElement) { $xml_array[$n]['name'] = $xml->name; if($xml->hasAttributes) while($xml->moveToNextAttribute()) $xml_array[$n]['attribute'][$xml->name] = $xml->value; $xml_array[$n]['value'] = ""; } else if($xml->nodeType == XMLReader::TEXT) { $xml_array[$n]['value'] = $xml->value; } } $xml->close(); return $xml_array; } /*How to use?*/ $test = xml_read("resim/referanslar.xml"); for ($i=0;count($deneme) > $i;$i++) { echo $test[$i][name] . " " . $test[$i][value] . " " . $test[$i][attribute] . "<br>"; } /*have fun :)*/

« previous php.notes (#171031) next »