开发者

margins in using php to conusme rss feed- a rookie needs help!

I a开发者_如何转开发m new to PHP.

I have a code to display an RSS feed but there is a big space between each item (the title/date and description).

Is it possible to eliminate those margins?

<?php
$feed = simplexml_load_file('http://online.wsj.com/xml/rss/3_7031.xml', 'SimpleXMLIterator');
$first3 = new LimitIterator($feed->channel->item, 0, 4);
foreach ($first3 as $item) {
     echo "<h4><a href='$item->link'target='_blank'>$item->title</a></h4>";
     preg_match('/(?:\w{3},\s)?\d{1,2}\s\w{3}\s\d{2,4}/', $item->pubDate, $m);
     echo isset($m[0]) ? "<h5>$m[0]<h5>" : '';echo "<h6>$item->description<h6>";

}
?>


I'd create a stylesheet and change the margins on h4, h5 and other elements which may have or inherit margins.

I'd recommending getting Firebug, then right clicking on the troublesome elements in Firefox and choosing Inspect Element from the context menu.

Then, on the right hand panel, select the Layout tab and have a visual look at the margins. If they are larger than you require, adjust via the CSS (you can also real time adjust using Firebug for some immediate feedback).

Then modify the CSS like so...

h3 {
    margin: 5px 3px 2px 1px; /* top right bottom left */
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜