[英]PHP To google spreadsheet (docs api) with zend - DOMDocument cannot parse XML
[英]DOMDocument cannot parse XML
我正在使用Zend_Feed_Atom
從網站獲取供稿,但收到此錯誤:
信息:
DOMDocument無法解析XML:DOMDocument :: loadXML()[domdocument.loadxml]:xmlParseEntityRef:實體中沒有名稱,行:827
我嘗試了另一個站點,但沒有錯誤。 我想知道為什么在該特定頁面上出現錯誤,以及該錯誤是什么意思。 我在網上看過,它說這是編碼方面的問題(我不太了解)。
我的代碼很簡單,它只是
if($type_feed == "atom"){
$nfeed = new Zend_Feed_Atom($address);
}elseif($type_feed == "rss"){
$nfeed= new Zend_Feed_RSS($address);
}
任何幫助都是極好的! 謝謝!
在這里看看: http : //www.php.net/manual/zh/class.domdocument.php#domdocument.props.recover
所有權。 啟用恢復模式,即嘗試解析格式不正確的文檔。 此屬性不是DOM規范的一部分,並且特定於libxml。
你可以試試:
$dom = new DOMDocument();
$dom->recover = true;
另外,請看一下我的實現: https : //gitlab.com/DeepRSS/Reader/blob/a2723735ff3e3cdd7d85649c92d0115211ea9a0d/src/Core/Service/ZendReader/FeedParser.php#L99
如果Feed被破壞了,那么它就被破壞了,我們對此無能為力。
解決此問題的一種方法是使用@
抑制錯誤。
if($type_feed == "atom"){
$nfeed = @new Zend_Feed_Atom($address);
}elseif($type_feed == "rss"){
$nfeed= @new Zend_Feed_RSS($address);
}
請注意,這並不理想,因為在調用new
時它將抑制所有操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.