【发布时间】:2019-03-05 09:51:36
【问题描述】:
我想在网页上显示 RSS 提要。目前我只得到标题和描述,但我也想得到图片。
<?php
$html = "";
$url = "http://rss.cnn.com/rss/edition.rss";
$xml = simplexml_load_file($url);
foreach ($xml->channel->item as $itm) {
$title=$itm->title;
$link=$itm->link;
$pubDate=$itm->pubDate;
$description=$itm->description;
$img=$itm->media;
}
?>
<div class="container">
<div class="row">
<div class="col-md-6">
<a href="<?php echo $link ?>" class="text text-primary"><?php echo $title; ?></a><br>
<span class="text text-info"><?php echo $pubDate; ?></span><br>
<p align="right" class="text text-info"><?php echo $description; ?></p>
<img src="<?php echo $img; ?>"></img>
</div>
</div>
</div>
<?php } ?>
【问题讨论】:
-
不工作先生
-
我稍微改写了你的问题,并删除了一些被普遍认为是多余的“绒毛”(例如“提前致谢”)。
标签: php xml rss-reader feed