PHP 版本:7.4.30
我使用 simplexml_load_file php 函式,
$rss = simplexml_load_file($url, 'SimpleXMLElement', LIBXML_NOCDATA);
xml rss 檔案[示例]:
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
<channel>
<title>AAA</title>
<link>https://aaa.com</link>
<description>description</description>
<item>
<title>PRODUCTS EXPO 2022 in 神戸 ダイジェスト</title>
</item>
</channel>
</rss>?
輸出標題[$rss->channel->item[0]->title] : PRODUCTS EXPO 2022 in ?¥???? ??€?,¤?,??,§?, 1??
如何獲得標題:神戸ダイジェスト PRODUCTS EXPO 2022
uj5u.com熱心網友回復:
我將這一行更改為 xml rss JP 字符以進行更正。一切都好。
$rss = simplexml_load_file($rsses[$i]['url'], 'SimpleXMLElement', LIBXML_NOCDATA);
至
$feed = file_get_contents($rsses[$i]['url']);
$rss = simplexml_load_string($feed);
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/522333.html
標籤:phpxml
上一篇:lxmlXPath回傳空串列
