Re: XML to Array

From: Date: Mon, 11 Mar 2013 13:22:07 +0000
Subject: Re: XML to Array
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-320458@lists.php.net to get a copy of this message
On Sun, Mar 10, 2013 at 6:28 PM, Karl DeSaulniers <karl@designdrumm.com> wrote: > > On Mar 10, 2013, at 6:03 AM, richard gray wrote: > >> On 10/03/2013 11:47, Karl DeSaulniers wrote: >>> >>> Hi Guys, >>> I am hoping someone can guide me or help me fix this issue. >>> I have been lost in the code for some time now. >>> I am trying to get the attributes of an xml node. >>> I have this code: >>> [snip] >> >> this may help -> >> >> http://stackoverflow.com/questions/1156957/php-xml-attribute-parsing >>> >>> I do admit I haven't the foggiest idea what I am doing here, so I am >>> noobing out here on how this php function is really working. >>> I got it off php.net and am trying to implement it in my code. Without my >>> addition it works well except it doesn't grab any attributes >>> which I need in order for my script to work properly. >>> >>> Any ideas on what I am doing wrong? >>> >>> TIA, >> >> >> HTH >> rich > > > > Thanks rich, > That uses simpleXML. I am using xml_parse_create. > Any ideas for xml_parse_create? I really like the way this function > puts everything into an array that I can traverse. I only need it to put > the attribute values in the array for the corresponding node and I am done. > *Sigh > > Thanks for your help, > > Best, > > > Karl DeSaulniers > Design Drumm > http://designdrumm.com > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > I came across this XML to JSON to an array some time ago. It might be something function xmlToArray($xml) { return json_decode(json_encode((array) simplexml_load_string($xml)),1); } -- Bastien Cat, the other other white meat

« previous php.general (#320458) next »