1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How do I convert JSON to XML?

Discussion in 'HTML & JavaScript' started by smooshie, Sep 4, 2010.

  1. smooshie

    smooshie Newbie

    Joined:
    Dec 27, 2009
    Messages:
    18
    Likes Received:
    2
    I'm working with an api that only returns json. I know there are ways to parse json with php as well, but i'm much more comfortable with xml. Any ideas how to convert it?
     
  2. 195471

    195471 Regular Member

    Joined:
    Oct 11, 2008
    Messages:
    417
    Likes Received:
    260
    Check this:

    Code:
    http://goessner.net/download/prj/jsonxml/
     
  3. paincake

    paincake Power Member

    Joined:
    Aug 18, 2010
    Messages:
    716
    Likes Received:
    3,099
    Home Page:
    JSON is sooo much easier to parse... Just use json_decode() and you'll instantly have all the values as variables...
     
    Last edited: Sep 17, 2010
  4. Crazy

    Crazy Jr. Executive VIP

    Joined:
    Jun 13, 2009
    Messages:
    640
    Likes Received:
    319
    Occupation:
    VB, C#, XHTML, CSS, PHP, MySQL, JavaScript, jQuery
    Location:
    Everywhere
    This. Why do you feel it necessary to go to XML? What's bothering you w/ JSON?
     
  5. deziner

    deziner Newbie

    Joined:
    Oct 22, 2010
    Messages:
    25
    Likes Received:
    15
    json_decode it and then use simplexml to convert it into xml ;)