how to parse images by using Rome RSS Parser
Do you know how to parse images by using rome parser?(java platform) I looked at some samples at rome parser documentation but it's clear. Can you provide me the sample c开发者_开发问答ode to parse images by using rome rss parser?
Regards Altaico
Rome is a RSS parser/generator. As a consequence, it has nothing to do with image parsing. However, if the content of some RSS feed is HTML, then you may consider as a valid extension of Rome the fact of grabbing image content.
As an example, considering this RSS feed item from the magnificient brother bricks site :
<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[…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>…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&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’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’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>
You may notice that the content:encoded tag contains one link to a flickr image : http://farm5.static.flickr.com/4084/4946649495_460861bd28.jpg
that some RSS clients are able to display as an image. However, it's not because they correctly parse the RSS feed, but rather because, beside being able to interpret correctly the RSS stream, they're able to interpret its content (in this case, some HTML fragment representing the entry to render).
As a consequence, having the ability to download and open image files is NOT a question of RSS parsing, but rather a question of interpreting correctly RSS content, that is NOT RSS per se, but rather encoded CDATA that one is able to understand as valid content, of any form (in this example, HTML).
you see that the image url is in the tag.. so try to parse that tag in your program (just add another tag where you parsed Title, pubDate, link etc) . then create a methot getContent to save all the content from tag in a String. and from there just do a stringTokenizer to get your image link (select the delimiter \" )
after you get the url, download it
search for download images Bitmap rss, and you'll find how to download with bitmap and draw the images in your program
精彩评论