This question already has an answer here:
this response get in a one variable,how to convert JSON response in xml in php script
{
"data":[
{
"id":"15",
"color_code":"#D9DD29",
"font_color_code":"#ed1b1b",
"type":"Big Chunes",
"is_fade":"1",
"is_Active":"1",
"delay_time":"0"
},
{
"id":"58",
"color_code":"#19A87D",
"font_color_code":"#ffffff",
"type":"Demo",
"is_fade":"1",
"is_Active":"1",
"delay_time":"0"
}
]
}
</div>
function array2xml($array, $xml = false){
if($xml === false){
$xml = new SimpleXMLElement('<result/>');
}
foreach($array as $key => $value){
if(is_array($value)){
array2xml($value, $xml->addChild($key));
} else {
$xml->addChild($key, $value);
}
}
return $xml->asXML();
}
$jSON = json_decode($raw_data, true);
$xml = array2xml($jSON, false);
echo '<pre>';
print_r($xml);