views:

29

answers:

2

Okay sample output data is below, it looks something like JSON, but it's not formatted exactly like JSON. So I am wondering, how can I get this data looking like XML, preferably with php? Thanks!

[{ action:'getallregions', reply:[{regionid:'1',name:'Blue',description:'Research Route',color:'508CEB',active:'true',parentRegionId:'0',parentRegion:''},{regionid:'4',name:'Green',description:'Vet School Route',color:'73BE69',active:'true',parentRegionId:'0',parentRegion:''},{regionid:'10',name:'Purple',description:'Loop route',color:'5300B5',active:'true',parentRegionId:'0',parentRegion:''}]}]

Here is the data on Pastie.org http://pastie.org/1045154 Thanks for your help.

A: 

You might be interested in topic "Is there some way to convert json to xml in PHP?"

Hope, that it helps you.

Eugene
A: 

I don't know if this is what you are looking for, but:

json_decode(preg_replace('/([a-z0-9]+):/i','"$1":',str_replace('\'','"',$data)))

Basically I found a way to make the input valid JSON. The you can convert the object to xml using the XML_Serializer.

narcisradu