Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to convert XML to JSON using PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 107
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: