简体   繁体   English

如何使用Rome RSS Parser解析图像

[英]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. 您知道如何使用rome解析器解析图像吗?(java平台)我看过rome解析器文档中的一些示例,但是很明显。 Can you provide me the sample code to parse images by using rome rss parser? 能否提供使用rome rss解析器解析图像的示例代码?

Regards Altaico 问候阿尔泰科

Rome is a RSS parser/generator. 罗马是一个RSS解析器/生成器。 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. 但是,如果某些RSS feed的内容是HTML,则可以将获取图像内容这一事实视为Rome的有效扩展。

As an example, considering this RSS feed item from the magnificient brother bricks site : 例如,考虑来自宏伟的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>

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. 您可能会注意到,content:encoded标记包含一个指向flickr图像的链接: http://farm5.static.flickr.com/4084/4946649495_460861bd28.jpg : http://farm5.static.flickr.com/4084/4946649495_460861bd28.jpg ,某些RSS客户端可以将其显示为图像。 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). 但是,这不是因为他们正确地解析了RSS feed,而是因为除了能够正确解释RSS流之外,他们还能够解释其内容(在这种情况下,某些HTML片段代表了要渲染的条目)。

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). 结果,具有下载和打开图像文件的能力不是RSS解析的问题,而是正确解释RSS内容的问题,这本身不是RSS,而是一个能够理解为有效的编码CDATA。内容,任何形式(在此示例中为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. 然后创建一个methot getContent以将标记中的所有内容保存在String中。 and from there just do a stringTokenizer to get your image link (select the delimiter \\" ) 然后从那里执行一个stringTokenizer来获取您的图像链接(选择定界符\\“)

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 搜索位图rss的下载图像,您将找到如何使用位图下载并在程序中绘制图像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM