tag:blogger.com,1999:blog-312300893061964297.post5926240885823859531..comments2008-08-12T18:17:37.731-07:00Comments on My SRC: PHP: XML to Array and backwardsleoSrhttp://www.blogger.com/profile/09731107791619864392noreply@blogger.comBlogger31125tag:blogger.com,1999:blog-312300893061964297.post-33702502117247046472008-07-02T08:45:00.000-07:002008-07-02T08:45:00.000-07:00I'm confused how to actually traverse this multidi...I'm confused how to actually traverse this multidimensional array.<BR/><BR/>if I have:<BR/>$xml = xml2ary(file_get_contents($url));<BR/><BR/>then my xml gets stored as an array successfully.<BR/><BR/>But how do I traverse it? I tried a for loop, but it's not working. I don't know the values that are in the array and all the examples you have assume that you know the keys. Can you help me with this?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-73223035726397593392008-06-22T09:47:00.000-07:002008-06-22T09:47:00.000-07:00Great! thanks a lot as I'v been hitting my head ag...Great! thanks a lot as I'v been hitting my head against the wall for a good week now.<BR/>At last a simple function to extract xml into a array and hich support multiples tags with the same name and supports attributes as well.<BR/>Really saved my daygprodhttp://gprod.wordpress.com/noreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-58725853101170413052008-06-05T16:37:00.000-07:002008-06-05T16:37:00.000-07:00@Toddtry: $xml['ddd']['_c']['onemore']['_c']['tt']...<B>@Todd</B><BR/><BR/>try: $xml['ddd']['_c']['onemore']['_c']['tt']['_a']['ss']['_v']['s1']<BR/><BR/>_c, _v, _a looks like it comes before the resultMavrickhttp://www.blogger.com/profile/13651655770293259486noreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-61434857522749742492008-05-19T11:53:00.000-07:002008-05-19T11:53:00.000-07:00Very awesome! If you have time, could you show an ...Very awesome! <BR/><BR/>If you have time, could you show an example of someone selecting the values of the tt element where the ss attribute equals s1?<BR/><BR/>This doesn't seem to work:<BR/>$xml['ddd']['_c']['onemore']['_c']['tt']['_a']['ss']['s1']['_v']Toddnoreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-56321952841273524402008-05-08T01:25:00.000-07:002008-05-08T01:25:00.000-07:00Wikkked, I spent 1 week looking for xml -> array a...Wikkked, I spent 1 week looking for xml -> array and array -> xml... checked out SPL, simpleXML but just came across this script and it works sweeet as... Q: How do you save the xml? e.g. saveXML()?? Thanks, James from NZ.James Starhttp://www.blogger.com/profile/08588150745648618010noreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-83353651057586534392008-03-10T16:30:00.000-07:002008-03-10T16:30:00.000-07:00Brilliant! Worked flawlessly! Can I buy you a Guin...Brilliant! Worked flawlessly! Can I buy you a Guiness?CDhttp://www.blogger.com/profile/00811521737129356652noreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-38177811259690441262008-01-19T19:01:00.000-08:002008-01-19T19:01:00.000-08:00Hey.. this is a super tool. Quick question for you...Hey.. this is a super tool. Quick question for you. I would like all attributes to have a numerical index. Is this possible? Example:<BR/><BR/>[ddd]<BR/>[onemore dd="55"]<BR/>[tt]333[/tt]<BR/>[tt ss="s1"]555[/tt]<BR/>[tt]777[/tt]<BR/>[/onemore]<BR/>[two]sdf rr[/two]<BR/>[/ddd]<BR/>(switched < to [, to post)<BR/>becomes this:<BR/><BR/> Array<BR/>(<BR/> [ddd] => Array (<BR/> [0] => Array (<BR/> [_c] => Array (<BR/> [onemore] => Array (<BR/> [0] => Array (<BR/> [_a] => Array (<BR/> [dd] => 55<BR/> )<BR/> [_c] => Array (<BR/> [tt] => Array (<BR/> [0] => Array (<BR/> [_v] => 333<BR/> )<BR/>...<BR/><BR/>any ideas?<BR/>This way I can use a uniform parse on all depths of the array, instead of checking if key [0] exists, and so on... THanksdyreknycnoreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-75699216621301553062008-01-15T11:29:00.000-08:002008-01-15T11:29:00.000-08:00Excelent, thanks a lot.Hay to wigle with it a litt...Excelent, thanks a lot.<BR/>Hay to wigle with it a little, but it served it's purpose.<BR/>Only script around that did this thing.<BR/>Of course when you have acces to PHP5 there's simpleXML.Agustino.Onoreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-41910738498898932952008-01-12T11:02:00.000-08:002008-01-12T11:02:00.000-08:00I changed: elseif (isset($r['_v'])) $re...I changed:<BR/> elseif (isset($r['_v'])) $res[]=$r['_v']<BR/>to:<BR/> elseif (isset($r['_v'])) $res[]=htmlspecialchars($r['_v'])<BR/>.<BR/><BR/>Now values like "hal&lo" will go well.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-11991157961689431532008-01-03T11:53:00.000-08:002008-01-03T11:53:00.000-08:00Plug&play ... really!! Thks.Plug&play ... really!! Thks.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-73979320046820167862007-12-19T02:11:00.000-08:002007-12-19T02:11:00.000-08:00Thanks a lotThanks a lotgeorgnoreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-16878045217565496102007-09-26T17:45:00.000-07:002007-09-26T17:45:00.000-07:00PERFECT!!! I have been looking around FOREVER for ...PERFECT!!! I have been looking around FOREVER for a nice xml=>array class/functions out there. I modified your program to be class-based, but other than that, this is SAAAAWEEEEET!!! I love the fact that it standardizes everything...like if you have a subarray, it automatically sets it up to have a 0 index, rather than waiting until there are multiple children before making it. That is easily the sweetest thing that I have ever seen!!!!!!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-18342821984339873952007-09-26T06:56:00.000-07:002007-09-26T06:56:00.000-07:00very cool script, thanks - learning this stuff and...very cool script, thanks - learning this stuff and this is very useful.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-18909628333800396652007-09-21T16:35:00.000-07:002007-09-21T16:35:00.000-07:00Excellent script ... thanks for saving many hours ...Excellent script ... thanks for saving many hours of workAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-51845083873938305702007-09-10T06:14:00.000-07:002007-09-10T06:14:00.000-07:00greate script... but how do i escape or other htm...greate script... but how do i escape <A></A> or other html tags from beeing arrayed? :DAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-2063195473759017682007-08-31T15:38:00.000-07:002007-08-31T15:38:00.000-07:00awesome script, thanks! Nice logical structure and...awesome script, thanks! Nice logical structure and saved me a lot of time :)James Littlehttp://www.jameslittle.me.uknoreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-764803556777251682007-08-28T03:58:00.000-07:002007-08-28T03:58:00.000-07:00Thanks for saving me hours of work!Thanks for saving me hours of work!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-80107183284639842182007-08-21T14:25:00.000-07:002007-08-21T14:25:00.000-07:00Thanks a lot for the BRILLIANT script!!! :D You sa...Thanks a lot for the BRILLIANT script!!! :D <BR/><BR/>You save me from hours of headaches! ^__^lionlancernoreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-35206950304992943092007-08-09T11:36:00.000-07:002007-08-09T11:36:00.000-07:00Thank you ! This is a nice script that solved a pa...Thank you ! This is a nice script that solved a part of my problem.Andreihttp://dev.spartancoder.comnoreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-42954271447571580572007-06-18T23:42:00.000-07:002007-06-18T23:42:00.000-07:00Hola, bro!A nice piece of work.1. ary2xml() return...Hola, bro!<BR/><BR/>A nice piece of work.<BR/><BR/>1. ary2xml() returns xml without end tag. Is it a feature?<BR/>2. May be it is better to have it with a header which states that is xml script&<BR/><BR/>Of course, I made these changes and using it. If anybody needs this function with above features included, just let me know at sapargali at gmail dot com.Saparhttp://www.blogger.com/profile/05063300695482329162noreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-87089597981131382602007-06-05T15:03:00.000-07:002007-06-05T15:03:00.000-07:00GREAT! Thanks! ;-)GREAT! Thanks! ;-)Edersonhttp://www.blogger.com/profile/00247932474204331192noreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-55806866575363022692007-05-15T21:29:00.000-07:002007-05-15T21:29:00.000-07:00You're a lifesaver. Quite a brilliant little scrip...You're a lifesaver. Quite a brilliant little script. EXACTLY what I needed.deohttp://www.blogger.com/profile/11558256016218624783noreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-7319897675283915942007-04-14T10:12:00.000-07:002007-04-14T10:12:00.000-07:00Hi all!the Mauricio's CDATA hack is there: http://...Hi all!<BR/><BR/>the Mauricio's CDATA hack is there: http://forums.kayako.com/showthread.php?t=11269<BR/><BR/>Search "// small hack ;)" over the page; above this text is the hack.<BR/><BR/><BR/>Bye!!Eqheshttp://www.blogger.com/profile/09869998163343565715noreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-30446826237935386832007-03-27T02:01:00.000-07:002007-03-27T02:01:00.000-07:00To Tomek: You got an error "No such file or direct...To Tomek: You got an error "No such file or directory" becouse of $xml_location = "'http..'" (superfluous single quotes)<BR/><BR/>To Mauricio: please send me by email your code about CDATA, and I'll add it into this post.leoSrhttp://www.blogger.com/profile/09731107791619864392noreply@blogger.comtag:blogger.com,1999:blog-312300893061964297.post-6416911522992067272007-03-25T19:06:00.000-07:002007-03-25T19:06:00.000-07:00Great piece of code! Thanks!Wouldn't be a good ide...Great piece of code! Thanks!<BR/>Wouldn't be a good idea adding support for html content on ary2xml function? I made a small mod for your code, adding the CDATA tag between the value (couldn't paste the code)<BR/><BR/>just my 2 cents, thanks ;)Mauriciohttp://www.blogger.com/profile/05497423712737353952noreply@blogger.com