当我试图解析站点地图数据时,我可以得到loc字段。
$sitemapContent = simplexml_load_file($publisher['url']);
foreach ($sitemapContent as $sitemapItem) {
dd($sitemapItem->loc); // Ouputs SitemapXMLElement containing loc and lastmod
}站点地图中有更多的字段,如:.新闻:新闻:出版新闻:名称
有没有一种通过$sitemapItem访问出版物名称的方法?
发布于 2022-10-10 14:05:07
克里斯·哈斯发表评论后,我找到了一个解决方案:
$newsNamespace = $sitemapItem->children('http://www.google.com/schemas/sitemap-news/0.9');这样我就可以访问新闻命名空间了。
https://stackoverflow.com/questions/74015964
复制相似问题