note 60121 deleted from ref.xml by nlopess

From: Date: Tue, 27 Dec 2005 14:43:39 +0000
Subject: note 60121 deleted from ref.xml by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-100789@lists.php.net to get a copy of this message
Note Submitter: CJ ---- i've been looking for some code wich makes me a well usable array, from "any" xml. but though here are extremely good implementations of parsers i havnt found it, so i made up a class wich makes an easy useable array. probably not rockstable but well formed xml worx (well it should) <?php ini_set("display_errors","1"); class q{ //builds ARRAY from XML function xmltoarray($xml); //builds ARRAY from VALS recived from parser function valtoar(&$val,&$pos,&$cdata); //rebuild XML from ARRAY function arraytoxml($cjxml,$depth=0); } $ix=new q(); $erg =$ix->xmltoarray('<object name="name2">alphatext?<element name="name" id="1"><![CDATA[text abc <de]]></element>objettext2<element name="name" id="2">text2</element><element name="name" id="3" /><!-- any --> objekttext</object>'); print_r($erg); $ergt=$ix->arraytoxml($erg); print($ergt); $ergi=$ix->arraytoxml($erg,-1); print($ergi); $erg =$ix->xmltoarray($ergi); print_r($erg); //it produes an array wich can be easiely used by programs without any special cases //its structure is /* [tag] [#] ["attributes"] [attribute]=>string ["values"] [#]=>string ["elements"] [tag] [#] ["attributes"] [attribute]=>string ["values"] [#]=>string ["elements"] [tag] [#] ....... # means any number tag means the tag of the element attribut means the attribut ....... */ //btw. array 2 xml builds the xml from this array, u see the code is simple since the array has no special cases ?>

« previous php.notes (#100789) next »