2
我想在Android中使用Pull Parser来获取image2和image3的值。如何在Pull Parser for Android中使用匹配标签获取XML内容?
<item>
<title>Title Goes Here!</title>
<picture><![CDATA[http://blahblah.image.jpg]]></picture>
<picture><![CDATA[http://blahblah.image2.jpg]]></picture>
<picture><![CDATA[http://blahblah.image3.jpg]]></picture>
</item>
...
case XmlPullParser.END_TAG
if (tagname.equalsIgnoreCase("item")
_feed.addItem(_item);
} else if (tagname.equalsIgnoreCase("title")) {
_item.setTitle(theString)
} else if (tagname.equalsIgnoreCase("picture")) {
_item.setLargeImage(theString)
} else if (tagname.equalsIgnoreCase("picture")) {
_item.setLargeImage2(theString)
} else if (tagname.equalsIgnoreCase("picture")) {
_item.setLargeImage3(theString)
}
break;
...
我可以解析并加载第一个图像,但是,我不知道下一步是获取其他图像?谢谢您的帮助。
不它似乎更有意义,存储在列表中的图像的URL,而不是独立的变量?无论如何,对于你当前的代码,你应该只有一个'tagname.equalsIgnoreCase(“picture”)'条件(在第一个'if'永远不会运行之后的任何东西)并且保持你已经处理了多少url的运行计数,然后您可以使用它来调用适当的设置器。 –
+1。保留一个列表变量,并附加您使用“图片”标签运行的URL。 – dmon