note 69805 added to ref.xml

From: Date: Thu, 21 Sep 2006 19:49:37 +0000
Subject: note 69805 added to ref.xml
Groups: php.notes 
Request: Send a blank email to php-notes+get-117392@lists.php.net to get a copy of this message
the task: xml to multidimensional array ok folks i tested millions... of solutions and none worked for me, none returned the real structure i did my own parser a while ago and i am using it, but it doesnt work in some cases so i was searching for an other one - damn the parser itself was adapted somwhere the heartpiece is the compact part, and there are open ends, was too lazy today to solve it... (and still am) so, im posting an example xml and my functions and hope someone else finds a solution, ill be back on monday ;) <?xml version="1.0"?> <root> <version>1.7</version> <skin caption="Blueline" /> <skin stylesheet="/skins/ichier_blueline/ichier_blueline.css" /> <colors c0="#000066" /> <colors c1="#becfe6" /> <subskin> <skin caption="green" /> <skin stylesheet="/skins/ichier_blueline/ichier_greenline.css" /> </subskin> <subskin> <caption>red</caption> <skin stylesheet="/skins/ichier_blueline/ichier_redline.css" /> </subskin> </root> in that case im doing this: <?php $xml2arr = new ixml_get_array(); $skin = ixml_compact_array($xml2arr->parse($file), true, 'all', true, false, true); ?> that should result in: Array ( [_DATA] => [root] => Array ( [_DATA] => [version] => 1.7 [skin] => Array ( [caption] => Blueline [stylesheet] => /skins/ichier_blueline/ichier_blueline.css ) [colors] => Array ( [c0] => #000066 [c1] => #becfe6 ) [subskin] => Array ( [skin] => Array ( [caption] => green [stylesheet] => /skins/ichier_blueline/ichier_greenline.css [_DATA] => ) ) [subskin] => Array ( [skin] => Array ( [caption] => red [stylesheet] => /skins/ichier_blueline/ichier_redline.css [_DATA] => ) ) ) ) if you leave the subskins it'll put out what it should: an array representing 1:1 what the xml says but when its getting deeper its evil as said: until subskins it works! - so everybody may use it for simple purposes until it got fixed :þ so far - here is my code: (i cleaned it a bit from my special error calls etc. but kept the current control output) ok, because the post was to long the code is at www.ichier.de/files/xml.txt hope it helps somebody ... and maybe someone has an idea whats wrong :P i know its not really a performance-ace, but its closest to what i need niko ---- Server IP: 217.174.203.10 Probable Submitter: 88.73.64.122 ---- Manual Page -- http://www.php.net/manual/en/ref.xml.php Edit -- https://master.php.net/note/edit/69805 Del: integrated -- https://master.php.net/note/delete/69805/integrated Del: useless -- https://master.php.net/note/delete/69805/useless Del: bad code -- https://master.php.net/note/delete/69805/bad+code Del: spam -- https://master.php.net/note/delete/69805/spam Del: non-english -- https://master.php.net/note/delete/69805/non-english Del: in docs -- https://master.php.net/note/delete/69805/in+docs Del: other reasons-- https://master.php.net/note/delete/69805 Reject -- https://master.php.net/note/reject/69805 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117392) next »