【问题标题】:PHP Error: SimpleXMLElement::__construct()PHP 错误:SimpleXMLElement::__construct()
【发布时间】:2012-12-10 22:56:50
【问题描述】:

由于某种原因,我用来将 feedburner 计数为在我的网站 (http://ios-blog.co.uk) 周围使用的字符串的脚本已停止工作 :( 这是它抛出的错误:

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 2:     parser error : Opening and ending tag mismatch: meta line 1 and HEAD in /home/connect.php on line 83

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <TITLE>301 Moved</TITLE></HEAD><BODY> in /home/connect.php on line 83

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/connect.php on line 83

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 6: parser error : Opening and ending tag mismatch: HEAD line 1 and HTML in /home/connect.php on line 83

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: </BODY></HTML> in /home/connect.php on line 83

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/connect.php on line 83

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 7: parser error : Premature end of data in tag HTML line 1 in /home/connect.php on line 83

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: in /home/connect.php on line 83

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/connect.php on line 83

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/connect.php:83 Stack trace: #0 /home/connect.php(83): SimpleXMLElement->__construct('<HTML><HEAD><me...') #1 {main} thrown in /home/connect.php on line 83

这是我正在使用的 PHP:

//get cool feedburner count
$whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=iosdevblog";

//Initialize the Curl session
$ch = curl_init();

//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//Set the URL
curl_setopt($ch, CURLOPT_URL, $whaturl);

//Execute the fetch
$data = curl_exec($ch);

//Close the connection
curl_close($ch);
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];
echo $fb;
//end get cool feedburner count

文件很大 - 上面写着 83 与它相关的行:$xml = new SimpleXMLElement($data);

感谢大家的帮助:)

【问题讨论】:

    标签: php xml rss


    【解决方案1】:

    在这条线上看看这里

    警告:SimpleXMLElement::__construct() [simplexmlelement.--construct]: 301 移入 /home/connect.php 第 83 行

    它正在移动 HTTP 代码 301。

    如果您访问此链接

    https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=iosdevblog

    其实是404ing,没有XML。

    【讨论】:

      【解决方案2】:

      啊... feedburner 现在已弃用 - 这就是它突然停止的原因:( https://developers.google.com/feedburner/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-06-23
        • 2017-02-17
        • 2015-09-14
        • 1970-01-01
        • 1970-01-01
        • 2018-09-01
        相关资源
        最近更新 更多