$x=new xml();
$x->xml2json();
class xml
{
function xml2json()
{
$xml_object=NULL;
if (file_exists('test.xml'))
{
$xml_object = simplexml_load_file('test.xml');
}
else
{
exit('Failed to open test.xml.');
}
$xml_json=json_encode($xml_object);
echo $xml_json;
}
}