php simplexml 节点 `gphoto:width`
<?php
$url = 'https://picasaweb.google.com/data/feed/api/user/114098057261214889617/albumid/5282805114683350385?alt=rss&kind=photo&max-results=1';
$session = curl_init($url);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
$xml = simplexml_load_string($response);
$gphoto = $xml->channel->item->children('http://schemas.google.com/photos/2007');
echo $gphoto->width;//nothing return
?>
如何获取picasa rss图像的宽度和高度?谢谢。
这里的 xml 树:
<?xml version="1.0" encoding="UTF-8" ?>
- <rss xmlns:exif="http://schemas.google.com/photos/exif/2007" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gphoto="http://schemas.google.com/photos/2007" xmlns:media="http://search.yahoo.com/mrss/" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" version="2.0">
- <channel>
- <item>
...
<gphoto:width>1280</gphoto:width>
<gphoto:height>960</gphoto:height>
...
</item>
</channel>
</rss>
<?php
$url = 'https://picasaweb.google.com/data/feed/api/user/114098057261214889617/albumid/5282805114683350385?alt=rss&kind=photo&max-results=1';
$session = curl_init($url);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
$xml = simplexml_load_string($response);
$gphoto = $xml->channel->item->children('http://schemas.google.com/photos/2007');
echo $gphoto->width;//nothing return
?>
How to get picasa rss image width and height? Thanks.
the xml tree here:
<?xml version="1.0" encoding="UTF-8" ?>
- <rss xmlns:exif="http://schemas.google.com/photos/exif/2007" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gphoto="http://schemas.google.com/photos/2007" xmlns:media="http://search.yahoo.com/mrss/" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" version="2.0">
- <channel>
- <item>
...
<gphoto:width>1280</gphoto:width>
<gphoto:height>960</gphoto:height>
...
</item>
</channel>
</rss>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现在处理 google API feed 时删除命名空间更容易。
I find it easier to remove the namespaces when dealing with the google API feeds.