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
你剛剛度過我的一天!通過根據您的建議回饋提要的內容,我獲得了正確格式化的XML提要的鏈接,即[link](http://artistdata.sonicbids.com/john-latini/shows/xml/future )。現在一切都很美妙!謝謝哥們! – R1Racer