Thursday, November 19, 2009

How to create a style sheet for xml, rss feeds?

This is a small RSS feed that has 2 items in it. Is it possible to create a stylesheet for rss feeds, so for example make all descriptions in the feeds be underlined? If so how, or could you give me an example please?





Thanks





%26lt;?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?%26gt;


%26lt;rss version=\"2.0\"%26gt;


%26lt;channel%26gt;


%26lt;item%26gt;


%26lt;description%26gt;Tony Blair defends his close relationship with the US, following a scathing report from a Chatham House expert.%26lt;/description%26gt;


%26lt;link%26gt;%26lt;/link%26gt;http://news.bbc.co.uk/go/rss/-/1/hi/uk_p...


%26lt;/item%26gt;


%26lt;item%26gt;


%26lt;description%26gt;Tony Blair defends his close relationship with the US, following a scathing report from a Chatham House expert.%26lt;/description%26gt;


%26lt;link%26gt;%26lt;/link%26gt;http://news.bbc.co.uk/go/rss/-/1/hi/uk_p...


%26lt;/item%26gt;


%26lt;/channel%26gt;


%26lt;rss%26gt;

How to create a style sheet for xml, rss feeds?
This small style sheet will make all your descriptions in your feed underlined





%26lt;style type="text/css"%26gt;


description {


text-decoration: underline;


}


%26lt;/style%26gt;





you can save this style sheet in file, example "style.css" and attach to your feed.


But notice: When you save style sheet as file the "%26lt;style" ...%26gt; and %26lt;/style%26gt; tags must be removed!





Here is example feed with style sheet:





%26lt;?xml version="1.0" encoding="ISO-8859-1" ?%26gt;


%26lt;?xml-stylesheet type="text/css" href="http://yourdomain.com/style.css"?%26gt;


%26lt;rss version="2.0"%26gt;


%26lt;channel%26gt;


%26lt;item%26gt;


%26lt;description%26gt;Tony Blair defends his close relationship with the US, following a scathing report from a Chatham House expert.%26lt;/description%26gt;


%26lt;link%26gt;http://news.bbc.co.uk/go/rss/-/1/hi/uk_p...


%26lt;/item%26gt;


%26lt;item%26gt;


%26lt;description%26gt;Tony Blair defends his close relationship with the US, following a scathing report from a Chatham House expert.%26lt;/description%26gt;


%26lt;link%26gt;http://news.bbc.co.uk/go/rss/-/1/hi/uk_p...


%26lt;/item%26gt;


%26lt;/channel%26gt;


%26lt;rss%26gt;
Reply:if the previous answer works, let me know... I would assume any rss reader (including the one you found) would ignore the directive ... but a simple web browser might handle it when viewing the rss directly. but it would need a FULL stylesheet to show each of the different tags... very messy!


1 comment:

  1. Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write ups thanks once again.
    flash to html5 converter

    ReplyDelete