Currently I am using this code to pull a RSS feed from Yahoo Weather but I would like to style it the way I want but I am not sure how.
<?php
$doc = new DOMDocument();
$doc->load('http://xml.weather.yahoo.com/forecastrss/10013_f.xml');
$channel = $doc->getElementsByTagName("channel");
foreach($channel as $chnl)
{
$item = $chnl->getElementsByTagName("item");
foreach($item as $itemgotten)
{
$describe = $itemgotten->getElementsByTagName("description");
$description = $describe->item(0)->nodeValue;
echo $description;
}
}
?>
There are 2 options:
Option 1
A different approach to the previous answer: If you look at the actual XML file, then you’ll also see that the same description is also enclosed in individual tags:
There’s no reason why you can’t query all this data seperately and wrap it all in whatever HTML tags you want
To get the attributes from, for example, the
conditionsattributes, this works:Option 2
If you do choose the approach suggested in the previous answer, don’t forget that you can only use the HTML Tags used within the description (unless you do all sorts of string manipulation within PHP), but you can still use / style those tags by using cascading styles in your CSS:
…and so on