Hello readers, In this blog I guide you "How to convert XML to JSON using PHP"
Below is the 2 example converting XML to JSON.
1. example
$xml = simplexml_load_string($xml_string);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
2. exapmle
foreach($xml->children() as $state)
{
$states[]= array('state' => (string)$state->name);
}
echo json_encode($states);
0 Comment(s)