Possible Duplicate:
PHP convert XML to JSON
Here is what my a sample of my output XML looks like:
<item>
<Barcode>0602527522593</Barcode>
<albumid>1818</albumid>
<Title>Gold</Title>
<Country>Sweden</Country>
<Format>CD</Format>
<Length></Length>
<Number_of_Discs></Number_of_Discs>
<Type>album</Type>
<Description></Description>
<Band_or_Artist>Adams, Ryan</Band_or_Artist>
</item>
Is there an easy to use built-in PHP function or add-in to quickly convert this to JSON and output it? If it’s not built-in, which extension should I use?
You can use SimpleXML (http://php.net/manual/en/book.simplexml.php) to read the XML input and then json_encode (http://php.net/manual/en/book.json.php) to create the output.
You probably just want to iterate over the node list and put everything in an array using the tag names as keys, should be fairly simple.