- json_decode: documentation ( source)
- simplexml_load_string: documentation ( source)
- print_r: documentation ( source)
- json_encode: documentation ( source)
<?php
$xmlString= '<?xml version="1.0" encoding="UTF-8" ?>
<DATA>
<playList>
<timeStamp>201505261220</timeStamp>
<picPlayList>
<PlayMode>Sequential</PlayMode>
<File>1.jpg</File>
<File>10.jpg</File>
<File>11.jpg</File>
<File>12.jpg</File>
<File>13.jpg</File>
<File>14.jpg</File>
</picPlayList>
<videoPlayList>
<video>
<PlayMode>Sequential</PlayMode>
<Screen>FIRST</Screen>
<Type>Normal</Type>
<File>9423dgg012.mp4</File>
<File>letoutong15.mp4</File>
<File>fengjing1.mp4</File>
<File>fengjing2.mp4</File>
<File>fengjing3.mp4</File>
</video>
<video>
<PlayMode>Random</PlayMode>
<Screen>SECOND</Screen>
<Type>Normal</Type>
<File>9423dgg012.mp4</File>
<File>letoutong15.mp4</File>
<File>fengjing1.mp4</File>
<File>fengjing2.mp4</File>
<File>fengjing3.mp4</File>
</video>
</videoPlayList>
<HtmlViewList>
<PlayMode>Sequential</PlayMode>
<Screen>SECOND</Screen>
<Type>Normal</Type>
<URL>www.lotto-pass.cn/xxx/xxx/xxx</URL>
<URL>www.lotto-pass.cn/xxx/xxx/xxx</URL>
<URL>www.lotto-pass.cn/xxx/xxx/xxx</URL>
<URL>www.lotto-pass.cn/xxx/xxx/xxx</URL>
<Refresh>15</Refresh>
</HtmlViewList>
</playList>
</DATA>
';
$result_array = $xml_array = json_decode(json_encode(simplexml_load_string($xmlString)), true);
echo "\nOutput:\n";
print_r($result_array);
echo "\nThe Json output\n";
echo json_encode($result_array);
?>