xml解析器在android中获取图像url

时间:2015-12-22 08:24:01

标签: java android xml

我想从xml rss中读取一些数据。例如,这是我的xml项目:

    <item>
<title>
Oracle settles with the FTC over 'deceptive' Java security promises
</title>
<pubDate>Mon, 21 Dec 2015 13:39:00 -0800</pubDate>
<author>Katherine Noyes</author>
<dc:creator>Katherine Noyes</dc:creator>
<description>
<![CDATA[
<article> <section class="page"> <p> Security issues have long bedeviled users of Oracle's Java SE, and on Monday the Federal Trade Commission's efforts to address the problem finally came to fruition.</p><p> Oracle agreed to settle <a href="https://www.ftc.gov/system/files/documents/cases/151221oraclecmpt.pdf">charges</a> that it deceived consumers about the security provided by updates to its Java Standard Edition software, which is installed on some 850 million computers around the world, the FTC announced.</p><p> “When a company’s software is on hundreds of millions of computers, it is vital that its statements are true and its security updates actually provide security for the software,” said Jessica Rich, director of the FTC’s Bureau of Consumer Protection.</p><p class="jumpTag"><a href="/article/3017124/java-development/oracle-settles-with-the-ftc-over-deceptive-java-security-promises.html#jump">To read this article in full or to leave a comment, please click here</a></p></section></article>
]]>
</description>
<link>
http://www.computerworld.com/article/3017124/java-development/oracle-settles-with-the-ftc-over-deceptive-java-security-promises.html#tk.rss_all
</link>
<media:thumbnail url="http://zapt0.staticworld.net/images/article/2015/10/20151027-oracle-sun-logo-100625251-primary.idge.jpg"/>
<media:content url="http://zapt0.staticworld.net/images/article/2015/10/20151027-oracle-sun-logo-100625251-primary.idge.jpg"/>
<categories>
<category>Java Development</category>
<category>Application Development</category>
</categories>
</item>

现在我想从中获取图片网址。现在我的代码是:

if(localName.equalsIgnoreCase("enclosure")){
        if(attributes.getValue("media:thumbnail") != null){
            imgurl = attributes.getValue("media:thumbnail").toString();
            Log.d("MyRssParser", imgurl);
        }
    }

但这段代码似乎有问题。对不起我的简单问题!我是这个领域的新手! 谢谢你的帮助 。

1 个答案:

答案 0 :(得分:1)