note 81551 added to ref.xmlreader

From: Date: Mon, 03 Mar 2008 19:22:51 +0000
Subject: note 81551 added to ref.xmlreader
Groups: php.notes 
Request: Send a blank email to php-notes+get-136706@lists.php.net to get a copy of this message
<?php /* Read XML structure to associative array -- Using: $xml = new XMLReader(); $xml->open([XML file]); $assoc = xml2assoc($xml); $xml->close(); */ function xml2assoc(&$xml){ $assoc = NULL; $n = 0; while($xml->read()){ if($xml->nodeType == XMLReader::END_ELEMENT) break; if($xml->nodeType == XMLReader::ELEMENT){ $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->nodeType == XMLReader::TEXT) $assoc = $xml->value; } return $assoc; } ?> ---- Server IP: 195.54.192.44 Probable Submitter: 85.118.231.211 ---- Manual Page -- http://www.php.net/manual/en/ref.xmlreader.php Edit -- https://master.php.net/note/edit/81551 Del: integrated -- https://master.php.net/note/delete/81551/integrated Del: useless -- https://master.php.net/note/delete/81551/useless Del: bad code -- https://master.php.net/note/delete/81551/bad+code Del: spam -- https://master.php.net/note/delete/81551/spam Del: non-english -- https://master.php.net/note/delete/81551/non-english Del: in docs -- https://master.php.net/note/delete/81551/in+docs Del: other reasons-- https://master.php.net/note/delete/81551 Reject -- https://master.php.net/note/reject/81551 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136706) next »