- json_decode: documentation ( source)
- simplexml_load_string: documentation ( source)
- print_r: documentation ( source)
- json_encode: documentation ( source)
<?php
$xml = <<< END
<product>
<ref>32332</ref>
<name>Test 1</name>
<features>
<feature>
<name>Feature 1</name>
<value>Red</value>
</feature>
<feature>
<name>Feature 2</name>
<value>Large</value>
</feature>
</features>
</product>
END;
$object = simplexml_load_string($xml);
print_r(json_decode(json_encode($object), true));