如何使用 php 访问 flickr RSS feed 中的子标签?
我正在从我的 flickr RSS 提要中提取信息,但遇到了障碍。像图片 url 和标题之类的东西 位于简单的
if($item['title'] !== "")
$title = htmlspecialchars(stripslashes($item['title']));
else
$title = $settings['default_title'];
$url = $item['link'];
但是在 flickr RSS feed 中标签和描述是这样输出的
<media:category scheme="urn:flickr:tags">coffee coding</media:category>
<media:description type="html"> <p>even coffee isn't helping with coding today<br /> :(</p> </media:description>
我如何访问这些标签?我已经尝试过了
$tag = $item['media_category'];
$desc = $item['media_description'];
,但
$tag = $item['media:category'];
$desc = $item['media:description'];
似乎都不起作用?
I am pulling info from my flickr RSS feed and have hit a road bump. Things like the image url and title
are in simple <Title>
and <Link>
tags. And I get them like this
if($item['title'] !== "")
$title = htmlspecialchars(stripslashes($item['title']));
else
$title = $settings['default_title'];
$url = $item['link'];
But in the flickr RSS feed tags and descriptions are outputted like this
<media:category scheme="urn:flickr:tags">coffee coding</media:category>
<media:description type="html"> <p>even coffee isn't helping with coding today<br /> :(</p> </media:description>
How do I access these tags? I have tried
$tag = $item['media_category'];
$desc = $item['media_description'];
And
$tag = $item['media:category'];
$desc = $item['media:description'];
Neither seem to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要使用 SimpleXML 访问 XML 命名空间元素,请尝试以下操作:
这个问题中有更多信息。
To access the XML namespace elements using SimpleXML, try this:
Some more info in this question.