Php 打印atom web提要如何
我正在使用此代码打印atom web提要。如何访问链接rel='enclosure'中的一个映像?有人能帮我吗?我只想在屏幕上打印一张图像,但我不知道如何访问四个链接属性之一。我已经搜索了信息,但似乎对我没有帮助Php 打印atom web提要如何,php,atom-feed,Php,Atom Feed,我正在使用此代码打印atom web提要。如何访问链接rel='enclosure'中的一个映像?有人能帮我吗?我只想在屏幕上打印一张图像,但我不知道如何访问四个链接属性之一。我已经搜索了信息,但似乎对我没有帮助 <?php // read in an xml file $myFile = "http://www.deredactie.be/cm/vrtnieuws?mode=atom"; $feed = simplexml_load_file($myFil
<?php
// read in an xml file
$myFile = "http://www.deredactie.be/cm/vrtnieuws?mode=atom";
$feed = simplexml_load_file($myFile);
$xml = $feed->children('http://www.w3.org/2005/Atom');
echo "<h1>".$xml->title . "</h1>\n";
foreach ($xml->entry as $entries) {
$child = $entries->children('http://www.w3.org/2005/Atom');
// post title
echo "<h3>".$child->title . "</h3>\n";
// post author
// post content
if (!empty($child->summary)) echo htmlspecialchars($child->summary) . "<br />\n";
echo $child->content->asXML();
echo $child->updated;
echo $child->link;
}
?>
<entry>
<title>400 "Blockupy"-manifestanten opgepakt in Frankfurt</title>
<summary>In Frankfurt hebben betogers voor de derde dag op rij betoogd tegen de financiële crisis en de zware besparingen. 400 mensen zijn opgepakt.</summary>
<id>http://www.deredactie.be/permalink/1.1304838</id>
<published>2012-05-18T20:14:00.000+02:00</published>
<updated>2012-05-18T20:14:00.000+02:00</updated>
<link rel="self" type="application/atom+xml" title="400 "Blockupy"-manifestanten opgepakt in Frankfurt" href="http://www.deredactie.be/permalink/1.1304838?mode=atom"/>
<link rel="alternate" type="text/html" title="vrtnieuws - 400 "Blockupy"-manifestanten opgepakt in Frankfurt" href="http://www.deredactie.be/permalink/1.1304838"/>
<link rel="enclosure" href="http://media.vrtnieuws.net/2012/05/191629155ONL1205188400687.urlFLVLong.flv" type="video/x-flv" title=""Blockupy"-protest tegen banken in Frankfurt"/>
<link rel="enclosure" href="http://media.vrtnieuws.net/2012/05/191629155ONL1205188400687_urlThumbnailDir_tmb/0050.jpg" type="image/jpeg; format=thumbnail" title=""Blockupy"-protest tegen banken in Frankfurt"/>
<link rel="enclosure" href="http://www.deredactie.be/polopoly_fs/1.1304852!image/3646472733.jpg" type="image/jpeg"/>
</entry>
children('http://www.w3.org/2005/Atom');
echo“$xml->title。“\n”;
foreach($xml->entry as$entries){
$child=$entries->children('http://www.w3.org/2005/Atom');
//职称
回显“$child->title”。\n”;
//后作者
//帖子内容
如果(!empty($child->summary))回显htmlspecialchars($child->summary)。“
\n”;
echo$child->content->asXML();
echo$child->更新;
echo$child->link;
}
?>
400 "Blockupy和#034-法兰克福的manifestanten opgepakt
在法兰克福,hebben betogers voor de derde dag op rij在法国金融危机中扮演着重要角色。400人在奥普格帕克特。
http://www.deredactie.be/permalink/1.1304838
2012-05-18T20:14:00.000+02:00
2012-05-18T20:14:00.000+02:00
对不起,我用的是手机,所以我不能用
$result = $child->xpath('//link[@rel=\'enclosure\']');
while(list( , $node) = each($result)) {
echo "<img src='{$node['@href']}' />";
}
$result=$child->xpath('//link[@rel=\'enclosure\']);
while(列表(,$node)=每个($result)){
回声“;
}
既然你得到了超过1个链接,回显$child->link是不是很奇怪