如何使用Rome RSS Parser解析图像

时间:2010-09-01 07:34:18

标签: java parsing rss

你知道如何使用罗马解析器解析图像吗?(java平台)我在罗马解析器文档中查看了一些示例,但很明显。你能用rome rss解析器为我提供解析图像的示例代码吗?

此致 Altaico

2 个答案:

答案 0 :(得分:0)

Rome是一个RSS解析器/生成器。因此,它与图像解析无关。但是,如果某些RSS提要的内容是HTML,那么您可以将抓取图像内容的事实视为罗马的有效扩展。

例如,考虑来自宏观brother bricks站点的这个RSS提要项:

<item>
    <title>From the unknown chasms of space</title>
    <link>http://feedproxy.google.com/~r/TheBrothersBrick/~3/8g6XnrwJDlQ/</link>
    <comments>http://www.brothers-brick.com/2010/08/31/from-the-unknown-chasms-of-space/#comments</comments>
    <pubDate>Wed, 01 Sep 2010 04:20:49 +0000</pubDate>
    <dc:creator>Nannan</dc:creator>
            <category><![CDATA[LEGO]]></category>
    <category><![CDATA[Our Own Creations]]></category>
    <category><![CDATA[Space]]></category>

    <guid isPermaLink="false">http://www.brothers-brick.com/?p=16929</guid>
    <description><![CDATA[&#8230;comes my latest creation, a ship called Broken Regret. I strove for an ominous and organic looking craft by incorporating curves and spikes (best viewed on black). The result is something that looks much better in real life than on photos. This is due to the curves of the ship distorting our perception of its [...]]]></description>
        <content:encoded><![CDATA[<p>&#8230;comes my latest creation, a ship called Broken Regret. I strove for an ominous and organic looking craft by incorporating curves and spikes (best <a href=http://bighugelabs.com/onblack.php?id=4946649495&#038;size=large>viewed on black</a>). The result is something that looks much better in real life than on photos. This is due to the curves of the ship distorting our perception of its true shape and size (I had to do a lot of lens adjustments in Photoshop). Hopefully you&#8217;ll see what I mean when I post more pictures and a video in the upcoming days.</p>
<p><a href="http://www.flickr.com/photos/nannanz/4946649495/"><img src="http://farm5.static.flickr.com/4084/4946649495_460861bd28.jpg" width="500"></a></p>
<p>On another note, I want to mention that there are some incredible sellers on Bricklink who sent me last-minute parts to complete the ship at practically no cost. I&#8217;ve encountered many of you over the years, you know who you are, thank you.</p>
<img src="http://feeds.feedburner.com/~r/TheBrothersBrick/~4/8g6XnrwJDlQ" height="1" width="1"/>]]></content:encoded>
        <wfw:commentRss>http://www.brothers-brick.com/2010/08/31/from-the-unknown-chasms-of-space/feed/</wfw:commentRss>
    <slash:comments>0</slash:comments>
    <feedburner:origLink>http://www.brothers-brick.com/2010/08/31/from-the-unknown-chasms-of-space/</feedburner:origLink></item>

您可能会注意到content:encoded标签包含指向flickr图像的一个链接:http://farm5.static.flickr.com/4084/4946649495_460861bd28.jpg某些RSS客户端能够显示为图像。但是,这并不是因为它们正确地解析RSS源,而是因为除了能够正确解释RSS流之外,它们还能够解释其内容(在这种情况下,一些HTML片段表示要呈现的条目)。 / p>

因此,具有下载和打开图像文件的能力不是RSS解析的问题,而是解释正确的RSS内容的问题,这本身不是RSS,而是编码的CDATA,一个人能够理解为任何形式的有效内容(在本例中为HTML)。

答案 1 :(得分:0)

你看到图片网址在标签中.. 所以尝试在程序中解析该标记(只需在解析Title,pubDate,link等时添加另一个标记)。 然后创建一个methot getContent来保存String中tag的所有内容。 从那里只需要一个stringTokenizer来获取你的图像链接(选择分隔符\“)

获得网址后,下载

搜索下载图片Bitmap rss,你会发现如何使用位图下载并在程序中绘制图像