<?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);
?>
- Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
- Output:
Array
(
[playList] => Array
(
[timeStamp] => 201505261220
[picPlayList] => Array
(
[PlayMode] => Sequential
[File] => Array
(
[0] => 1.jpg
[1] => 10.jpg
[2] => 11.jpg
[3] => 12.jpg
[4] => 13.jpg
[5] => 14.jpg
)
)
[videoPlayList] => Array
(
[video] => Array
(
[0] => Array
(
[PlayMode] => Sequential
[Screen] => FIRST
[Type] => Normal
[File] => Array
(
[0] => 9423dgg012.mp4
[1] => letoutong15.mp4
[2] => fengjing1.mp4
[3] => fengjing2.mp4
[4] => fengjing3.mp4
)
)
[1] => Array
(
[PlayMode] => Random
[Screen] => SECOND
[Type] => Normal
[File] => Array
(
[0] => 9423dgg012.mp4
[1] => letoutong15.mp4
[2] => fengjing1.mp4
[3] => fengjing2.mp4
[4] => fengjing3.mp4
)
)
)
)
[HtmlViewList] => Array
(
[PlayMode] => Sequential
[Screen] => SECOND
[Type] => Normal
[URL] => Array
(
[0] => www.lotto-pass.cn/xxx/xxx/xxx
[1] => www.lotto-pass.cn/xxx/xxx/xxx
[2] => www.lotto-pass.cn/xxx/xxx/xxx
[3] => www.lotto-pass.cn/xxx/xxx/xxx
)
[Refresh] => 15
)
)
)
The Json output
{"playList":{"timeStamp":"201505261220","picPlayList":{"PlayMode":"Sequential","File":["1.jpg","10.jpg","11.jpg","12.jpg","13.jpg","14.jpg"]},"videoPlayList":{"video":[{"PlayMode":"Sequential","Screen":"FIRST","Type":"Normal","File":["9423dgg012.mp4","letoutong15.mp4","fengjing1.mp4","fengjing2.mp4","fengjing3.mp4"]},{"PlayMode":"Random","Screen":"SECOND","Type":"Normal","File":["9423dgg012.mp4","letoutong15.mp4","fengjing1.mp4","fengjing2.mp4","fengjing3.mp4"]}]},"HtmlViewList":{"PlayMode":"Sequential","Screen":"SECOND","Type":"Normal","URL":["www.lotto-pass.cn\/xxx\/xxx\/xxx","www.lotto-pass.cn\/xxx\/xxx\/xxx","www.lotto-pass.cn\/xxx\/xxx\/xxx","www.lotto-pass.cn\/xxx\/xxx\/xxx"],"Refresh":"15"}}}
- Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
- Fatal error: Call to undefined function json_decode() in /in/un2jd on line 55
Process exited with code 255. - Output for 4.4.5 - 4.4.9
- Fatal error: Call to undefined function: json_decode() in /in/un2jd on line 55
Process exited with code 255. - Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
- Fatal error: Call to undefined function: json_decode() in /in/un2jd on line 55
Process exited with code 255. - Output for 4.3.0 - 4.3.1
- Fatal error: Call to undefined function: json_decode() in /in/un2jd on line 55
preferences:
127.21 ms | 413 KiB | 5 Q