How to make this text feeds go underlined with PHP? (rss)?

This is part of a script that echos through rss feeds. Does anyone know how i could add styling to the feeds e.g. have them underlined without effecting the forloop?

echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<rss version=\"2.0\">\n<channel>\n";

foreach ($rs['items'] as $item) {

echo "<item>\n<link>$item[link]</link>\n<title>$item[title]</title>\n<description>$item[description]</description>\n<pubDate>$item[pubDate]</pubDate>\n</item>\n\n";


echo "</channel></rss>";

4 Answers

  • Anonymous
    1 decade ago
    Favorite Answer

    Apologies on behalf of the previous two answers for them not having a single clue as to what they are talking about.

    As previously noted, you cannot use CSS with an XML document.

    Unfortunately, XSLT will not accomplish what you are after, either.

    XSLT is not the XML version of CSS, as the above answer implies. XSLT is a set of instructions you use to render a given XML document as a different XML document, an XHTML document, or whatever.

    From what I gather, when you view the RSS feed you are creating in a browser window, you want see the text inside the <link> elements, or any URL-formatted character data, underlined.

    Well, that's up to the Web browser to decide how to render, and neither IE 6 nor Firefox 1.5 display XML link elements as underlined.

    In an XML document, just because an element is named <link>, that doesn't mean its contents is a hyperlink. And just because the character data inside an element takes the form or a URL, that doesn't mean you want it to be treated as an HTML link.

    You could use XSLT to render your XML feed as an HTML document, and then apply CSS to the resulting Web page, which could then underline your links:

    But to be very clear on the point, once you apply an XSLT to an XML document, you're no longer viewing the XML itself; you're viewing a representation of the XML document. It's like if you go to the amusement part and the hall of mirrors; the mirrors show a distortion of you, but none of those images are actually you. XSLT is a mirror of the XML document, not the XML document itself.

  • 1 decade ago

    I've said it before and I'll keep saying it! styling in rss is hard... some readers will ignore it some will show it. ATOM 1.0 handles namespaces and you can have full html in the description... other versions (RSS 2.0) do not always behave well with 'full' html.

    Since your reader is written in JS ... patch it to handle the underline where you want it underlined.

  • 1 decade ago

    Make an XSL stylesheet for the feed. CSS is OK if you are inserting your feed into an HTML template for displaying on the web.

    The XSL stylesheet is specifically designed for XML documents.

  • thadu
    Lv 5
    1 decade ago

    u can create a css file, and then add the class="" in the code

Still have questions? Get your answers by asking now.