【发布时间】:2014-03-19 11:52:07
【问题描述】:
虽然有很多选项可以将“普通”XML 转换为数组,但我非常想找到一种方法将这些数据转换为我可以用 PHP 处理的数组(它目前设计为由 JQuery 处理)
<?xml version="1.0" encoding="ISO-8859-15"?><root><data><![CDATA[ [{title_id: "284270",
track_id: "1548617",
artist: [[20670, 1, "Matthias Vogt", "matthias-vogt"]],
title: "The Wobble Track",
title_url: "/title/284270/the-wobble-track",
track_url: "/track/1548617/the-wobble-track",
label: [88, "Large Music", "large-music"],
genre: "Deep House",
genre_url: "/genre/13/deep-house",
catnumber: "LAR181",
promo: false,
duration: "5:54",
r_date: "2014-02-17",
price: {hbr: 1.99, wav: 2.74},
bought: false,
image: "http://static.traxsource.com/files/images/271306_large.jpg",
thumb: "http://static.traxsource.com/scripts/image.php/44x44/271306.jpg",
mp3: "http://preview.traxsource.com/files/previews/88/1324290-p.mp3",
waveform: "http://static.traxsource.com/files/wf/1324290-wf.png",
bpm: "120",
keysig: "Bmin"}
] ]]></data></root>
这个 xml 字符串中还有大约 99 个对象,所以为了简单起见,我只包含了 1 个
我想将一个数组转换为 JSON 或 PHP 数组 - 谢谢 :)
【问题讨论】: