简体   繁体   English

解析新闻:站点地图 urlset 中的新闻

[英]Parsing news:news in urlset of a sitemap

When I try to parse sitemap data and I can get loc field.当我尝试解析站点地图数据时,我可以获得 loc 字段。

$sitemapContent = simplexml_load_file($publisher['url']);

foreach ($sitemapContent as $sitemapItem) {
    dd($sitemapItem->loc); // Ouputs SitemapXMLElement containing loc and lastmod
}

...but in the sitemap there are more fields like this: ... news:news news:publication news:nameAcme</news:name> ...但在站点地图中还有更多这样的字段:... news:news news:publication news:nameAcme</news:name>

Is there a way to access the publication name via $sitemapItem?有没有办法通过 $sitemapItem 访问出版物名称?

After Chris Haas's comment, I found a solution:在 Chris Haas 的评论之后,我找到了一个解决方案:

$newsNamespace = $sitemapItem->children('http://www.google.com/schemas/sitemap-news/0.9');

This way I can access news namespace.这样我就可以访问新闻命名空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM