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
    • 111
    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

    1. $xml = simplexml_load_string($xml_string);
    2. $json = json_encode($xml);
    3. $array = json_decode($json,TRUE);

    2. exapmle

    1. foreach($xml->children() as $state)
    2. {
    3. $states[]= array('state' => (string)$state->name);
    4. }
    5. echo json_encode($states);

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: