2013-11-27 64 views
1

我一直在尝试过去几天来弄清楚为什么我的代码在本地完美工作,但在生产服务器上部署时失败。Artistdata.com RSS源解析在本地但不在生产服务器上工作

我的本地测试环境是10.7.2 Lion iMac上的最新MAMP。

基本上我需要从Artistdata.com获取某些XML RSS数据,以便将其插入到我正在处理的简单PHP驱动的非CMS网站中。

<!DOCTYPE html> 
<html> 
<head> 
<title>RSS FEED Parser</title> 
</head> 

<body> 

<?php 
    ini_set('display_errors',1); 
    ini_set('display_startup_errors',1); 
    error_reporting(-1); 

    # RSS Feed parser # 
    function getFeed($feed_url) { 
     $content = file_get_contents($feed_url); 
     $x = new SimpleXmlElement($content); 

     foreach ($x->show as $showEntry) { 
      echo '<div>';# date 
       $newDate = new DateTime($showEntry->date); 
       echo date_format($newDate, 'l, F j, Y'); 
      echo '</div>';# /date 

      # further data fetching, totally unrelated 
      # to the problem that I'm experiencing 
     } 
    } 
?> 

<!-- START FEED PARSING --> 
<div id="feed-data"> 
    <?php getFeed('http://feeds.artistdata.com/xml.shows/artist/AR-30CA266E4BEDD78F/xml/future'); ?> 
</div> 
<!-- END FEED PARSING --> 

</body> 
</html> 

我确定有更多的人有类似的问题,但我还没有找到一个可行的解决方案。

如果您有任何指示,我会非常感激。

编辑:忘了张贴的错误,所以在这里,他们都低于

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 1: parser error : Space required after the Public Identifier in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]:^in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 1: parser error : SystemLiteral " or ' expected in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]:^in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 1: parser error : SYSTEM or PUBLIC, the URI is missing in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]:^in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 9: parser error : Opening and ending tag mismatch: hr line 7 and body in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: </body></html> in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]:^in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 9: parser error : Opening and ending tag mismatch: body line 4 and html in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: </body></html> in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]:^in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 10: parser error : Premature end of data in tag html line 2 in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: in /home/*****/public_html/ssr/parse-feed.php on line 17 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]:^in /home/*****/public_html/ssr/parse-feed.php on line 17 

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/*****/public_html/ssr/parse-feed.php:17 Stack trace: #0 /home/*****/public_html/ssr/parse-feed.php(17): SimpleXMLElement->__construct('<!DOCTYPE HTML ...') #1 /home/*****/public_html/ssr/parse-feed.php(33): getFeed('http://feeds.ar...') #2 {main} thrown in /home/*****/public_html/ssr/parse-feed.php on line 17 

问题解决了,我用错了饲料,正确的是http://artistdata.sonicbids.com/john-latini/shows/xml/future

回答

1

这XML不看像RSS一样。它是由http://feeds.artistdata.com/_css/shows.xsd定义的特定格式。

错误消息都表示您获得的HTML(2.0)页面不是XML。我无法重现,我使用file_get_contents()获取XML。

尝试输出HTML页面,也许它有一些更多的信息。

echo file_get_contents('http://feeds.artistdata.com/xml.shows/artist/AR-30CA266E4BEDD78F/xml/future'); 
+0

你刚刚度过我的一天!通过根据您的建议回馈提要的内容,我获得了正确格式化的XML提要的链接,即[link](http://artistdata.sonicbids.com/john-latini/shows/xml/future )。现在一切都很美妙!谢谢哥们! – R1Racer

相关问题