我正在尝试使用他们的API从第三方Feed中获取数据。它所涉及的格式据称是XML,但与我未经训练的眼睛几乎没有相似之处。以下是用php回显屏幕的内容:
122701 29 Epound_10_-_Epound_20 13 Epound_20_-_Epound_30 1 Epound_30_-_Epound_40 4 Epound_40_-_Epound_50 11 532601 13 4896423 10 283701 6 0 29 0__-_100_ 29 BRAND NEW BOXED 8GB 4TH GEN STYLE MP4 PLAYER MUSIC VIDEO WITH IPOD CONNECTION LIMITED STOCK AT THIS PRICE! PINK RED BLUE SILVER PURPLE BLACK GREEN FEATURES USB 2.0 version with capacity: 8GB Holds Up to 1600 Songs 2 inch TFT Screen, 260K true colors display Support multiple music formats: MP1, MP2, MP3,WMA, http://r.3rdparty.com/r/uk/532601/122701/90/90/http%3A%2F%2Fi.ebayimg.com%2F00%2Fs%2FMzg1WDU5OQ%3D%3D%2F%24%28KGrHqN%2C%21lME6CWISze5BOsD3p%28T0%21%7E%7E60_1.JPG%3Fset_id%3D8800005007/voAX7N1WHJJIu1oTgPhOqVsRjHMhQEX45KQtKDk2t4o- 90 90 http://r.3rdparty.com/r/uk/532601/122701/auto/auto/http%3A%2F%2Fi.ebayimg.com%2F00%2Fs%2FMzg1WDU5OQ%3D%3D%2F%24%28KGrHqN%2C%21lME6CWISze5BOsD3p%28T0%21%7E%7E60_1.JPG%3Fset_id%3D8800005007/voAX7N1WHJJIu1oTgPhOqVsRjHMhQEX45KQtKDk2t4o- http://ecs-uk.3rdparty.com/ctl/go/sitesearchGo?.ts=1352310761409&.sig=v6kMZQynUtJjAqTcYY01ZY_OGEM-&offerId=81b44a3770af829494b013d20aaf433a&searchId=1076987819567_1352310761409_2488241&affiliationId=12345678&country=uk&wait=true&ecs=ok&contextLevel=1&merchantid=532601&comId=532601&catId=122701 http://3rdparty.com/p-mp3-players-122701/bush-mp3-8gb-19657960?partnerId=12345678 eBay.co.uk http://3rdparty.com/data/merchantlogos/532601/ebay-logo-640.jpg 80 24 122701-19657960 Bush MP3 8GB MP3 Players 11.49 2.99 2.99 14.48 0 1 false Sound & Vision:iPods & MP3 Players| iPods & MP3 Players Bush 567 Features: * Connections: 1 x 30 Pin Ipod connection port, 1 x 3.5mm jack headphone output * Playable formats: MP3, AMV, WMV, ASF Video, JPG, TXT, LRC, WAV * Suitable for use with Windows PCs and MAC * Integrated long lasting lithium-ion battery * Built-in equalizer with 7 presets * Built-in Clock * Integrated http://r.3rdparty.com/r/uk/4896423/122701/90/90/http%3A%2F%2Fecx.images-amazon.com%2Fimages%2FI%2F31IHNu5OI5L._SL160_.jpg/Nw1b8PcAtWqiL74fE7oiiBurTgUSoIiWBYGvjkSH8hc- 90 90 http://r.3rdparty.com/r/uk/4896423/122701/auto/auto/http%3A%2F%2Fecx.images-amazon.com%2Fimages%2FI%2F31IHNu5OI5L._SL160_.jpg/Nw1b8PcAtWqiL74fE7oiiBurTgUSoIiWBYGvjkSH8hc- http://ecs-uk.3rdparty.com/ctl/go/sitesearchGo?.ts=1352310761409&.sig=Zh1tMTvh5S8dhWh3uC7CZYgI7rc-&offerId=661a194e6394057cf5315e16c23802b3&searchId=1076987819567_1352310761409_2488241&affiliationId=12345678&country=uk&wait=true&ecs=ok&contextLevel=1&merchantid=4896423&comId=4896423&catId=122701 http://3rdparty.com/p-mp3-players-122701/atlantic-agsil8-8gb-19803999?partnerId=12345678 Amazon Marketplace http://3rdparty.com/data/merchantlogos/4896423/Amazon_marketplace.gif 80 24 122701-19803999 Atlantic AGSIL8 8GB MP3 Players 11.99 3.99 3.99 15.98 0 1 Usually dispatched within 1-2 business days false 0608938410283 Electronics & Photo/Categories/Portable Sound & Vision/MP3 & Digital Media Players Atlantic 11695 brand new 8gb mp4 player very similar to the ipod nano,ipod chargers also work on this 2) Support multi-lanuages:English,French,German, Itlian,Spainish,ect 26 lanuages. 3) Play Mp3 4) Play movies 5) ID3 Lyrics display 6)
我的问题是,如何使用php转换它并提取数据?似乎没有像我看到的XML数据示例中那样的字段名,例如“标题”,“图像”等。
我已阅读此Stack Overflow问题,但它对此Feed没有帮助:
提前致谢。
答案 0 :(得分:0)
如果您不想阅读xml数据,请按照这些步骤进行操作
$ xmlURL =“你的xml网址在这里”;
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $xmlURL);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-type: text/xml'
));
$content = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
$obj = new SimpleXMLElement($content);
echo "<pre>";
var_dump($obj);
echo "</pre>";
}
catch(Exception $e){
var_dump($e);exit;
}
您将获得整个xml文件的数组格式。
感谢。