Im使用rome 1.0爲我的Java應用程序生成RSS。有效的RSS 2.0使用羅馬
在我的Java:
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType("rss_2.0");
feed.setTitle("My Site");
feed.setLink("http://example.com");
feed.setDescription("Test Site.");
List<SyndEntry> entries = new ArrayList<SyndEntry>();
SyndEntry entry = null;
SyndContent description = null;
entry = new SyndEntryImpl();
entry.setTitle("Entry1");
entry.setLink("http://example.com/entry1");
entry.setPublishedDate(new Date());
description = new SyndContentImpl();
description.setType("text/html");
description.setValue("This is the content of entry 1.");
entry.setDescription(description);
entries.add(entry);
feed.setEntries(entries);
Writer writer = new FileWriter("/home/jr/Desktop/stream.xml");
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed,writer);
writer.close();
生成RSS:
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
<title>My Site</title>
<link>http://example.com</link>
<description>Test Site.</description>
<item>
<title>Entry1</title>
<link>http://example.com/entry1</link>
<description>This is the content of entry 1.</description>
<pubDate>Fri, 09 Nov 2012 01:28:57 GMT</pubDate>
<guid>http://example.com/entry1</guid>
<dc:date>2012-11-09T01:28:57Z</dc:date>
</item>
</channel>
</rss>
當RSS被驗證here,它具有以下建議:
- 項目應不包括pubDate和dc:日期
- M issing原子:與rel =「self」鏈接
如何在羅馬圖書館推薦?生成的RSS是否正常?
謝謝。
部分回答[原子:聯繫在使用羅馬RSS](http://stackoverflow.com/questions/18112949/atomlink-in-rss-using-rome)。 – Joe
只是想提一下,@ JoshC13的答案確實有效,但它應該應用於'SyndEntryImpl'而不是'SyndFeedImpl',因爲重複的日期發生在'- '元素 –