使用 simplexml_load_file() php,XML RSS 的标题出现 JP 字符错误
P粉032900484
P粉032900484 2024-04-03 21:22:05
0
1
318

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] : 2022年产品博览会在南非举行ˆ< /p>

如何获得标题:神户文摘2022年产品博览会

P粉032900484
P粉032900484

全部回复(1)
P粉729436537

我将此行更改为 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);
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!