Back to News
Advertisement
Advertisement

⚡ Community Insights

Discussion Sentiment

100% Positive

Analyzed from 141 words in the discussion.

Trending Topics

#feed#xmlns#http#www#org#xml#atom#style#version#encoding

Discussion (1 Comments)Read Original on HackerNews

dfabulichabout 4 hours ago
Now seems a good time to mention that you can beautify your XML RSS/Atom feeds without XSLT using CSS and JS.

You can add a stylesheet to an Atom feed by adding a <link> tag with an xmlns attribute, like this:

    <?xml version="1.0" encoding="utf-8"?>
    <feed xmlns="http://www.w3.org/2005/Atom">
        <link rel="stylesheet" href="style.css" xmlns="http://www.w3.org/1999/xhtml" />
        <!-- ... the rest of the feed goes here ... -->
Or add styles directly with a <style> tag:

    <?xml version="1.0" encoding="utf-8"?>
    <feed xmlns="http://www.w3.org/2005/Atom">
        <style xmlns="http://www.w3.org/1999/xhtml"><![CDATA[
            * { color: red; }
        ]]></style>
        <!-- ... the rest of the feed goes here ... -->
You can even run JavaScript when users browse to your feed like this:

    <?xml version="1.0" encoding="utf-8"?>
    <feed xmlns="http://www.w3.org/2005/Atom">
        <script src="script.js" xmlns="http://www.w3.org/1999/xhtml" />
        <!-- ... the rest of the feed goes here ... -->
You can use JS to transform your XML, just like you can (could) with XSLT.