1 (edited by nakome 2013-03-06 20:05:26)

Topic: Encode xml to json

I ask a question,
this is a good idea to convert xml to json?.

<?php
    // Main engine defines
    define('DS', DIRECTORY_SEPARATOR);
    define('ROOT', rtrim(dirname(__FILE__), '\\/'));
    define('BACKEND', false);
    define('MONSTRA_ACCESS', true);
    // Load Engine bootstrap file 
    //require_once ROOT. DS . 'monstra'. DS . 'bootstrap.php';
    // Load Engine init file (Only monstra 2.2.0)
    require_once ROOT. DS . 'engine'. DS . '_init.php';
    // Name of table.
    $table = 'pages';
    // Load table.
    $xml   = XML::loadfile(STORAGE.DS.'database'.DS.$table.'.table.xml');
    // Give me access XMLHttpRequest
    header('Access-Control-Allow-Origin: *');
    // Encode to json.
    echo json_encode($xml);
?>

This is json data

Sample get json data

..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website