开发者

how to convert rss to html using java/j2ee?

.How can i conv开发者_StackOverflow中文版ert rss to html to display it effectively?


You could either use CSS to format the XML of the RSS feed directly or you could apply and XSLT to transform RSS into (X)HTML.

The following page is a good starting point for this:

Making RSS Pretty


you can use XSLT, or any java XML parser and write your own HTML. Like RssParser

Also see the question at SO: How to write an RSS feed with Java?


http://www.clapper.org/software/java/curn/

curn supports several output formats; you can configure one or more output handlers in curn's configuration file. A sample of curn's HTML output is herehere. A sample of curn's plain text output is here. curn supports, and uses internally, the FreeMarker template engine; you can easily generate another output format by writing your own FreeMarker template. In addition, you can write your own output handlers, in Java or in any scripting language supported by the Apache Jakarta Bean Scripting Framework (BSF) or (in Java 6) the javax.script API. See Writing Your Own Output Handler in the curn User's Guide for more details.


You need to parse the the XML/RSS so find the items that you need and then html decode the description so the RSS item below would turn into

<item>
  <title>Site update</title>
  <link>http://www.theautomatedtester.co.uk/presentations/automated_performance_monitor_and_reporting.htm</link>
  <description>
    &lt;p&gt;I have put a copy of my Google Test Automation Conference Slides up as well as the video from YouTube. There is also a link to the blog post about the work that David Henderson and I did for the talk.&lt;/p&gt;
  </description>
</item>

turns into

<p>I have put a copy of my Google Test Automation Conference Slides up as well as the video from YouTube. There is also a link to the blog post about the work that David Henderson and I did for the talk.</p> 

that can be rendered in a browser

EDIT SINCE QUESTION HAS CHANGED

http://java-source.net/open-source/rss-rdf-tools http://java.sun.com/developer/technicalArticles/javaserverpages/rss_utilities/


If you're prepared to program a little, you can use SaX or JDOM to fill data in a model (class representing elements in the RSS feed) and then process the model to output it to HTML. SaX is a standard API and is event driven. JDOM, on the other hand, loads the information from an RSS into a tree structure.

Tutorials:
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JAXPSAX.html
http://www.javaworld.com/javaworld/jw-05-2000/jw-0518-jdom.html

JDOM home page: http://www.jdom.org/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜