sax を使用して 1 つの Android xml 解析を開発する必要があります。
これは私のxmlフィードです:
<root>
<Categories>
<Category name="book">
<Articles>
<article articleid="170" title="java programming">
<thumb_image>
<image url="http://website/var/tmp/thumb_2536_design_pavitra-rajaram_1_thumb_dec2012__forfeed.jpeg"/>
</thumb_image>
<images>
<image url="http://food/dec2012/1_chef-olaf-niemeier_main_dec2012.jpg" alttext="Chef Olaf Niemeier"/>
<image url="http://food/dec2012/2_chutneys-from-hamburg_main_dec2012.jpg" alttext="Chef Olaf Niemeier"/>
</images>
</article>
<article articleid="171" title="Android programming">
<thumb_image>
<image url="http://website/var/tmp/thumb_2220_1_itc-grand-chola-chennai_main_dec2012__forfeed.jpeg"/>
</thumb_image>
<images>
<image url="http://food/dec2012/1_chef-olaf-niemeier_main_dec2012.jpg" alttext="Chef Olaf Niemeier"/>
<image url="http://food/dec2012/2_chutneys-from-hamburg_main_dec2012.jpg" alttext="Chef Olaf Niemeier"/>
</images>
</article>
</Article>
</Category>
<Category name="Animals">
<Articles>
<article articleid="81" title="Dog">
<thumb_image>
<image url="http://website/var/tmp/thumb_2220_1_itc-grand-chola-chennai_main_dec2012__forfeed.jpeg"/>
</thumb_image>
<images>
<image url="http://food/dec2012/1_chef-olaf-niemeier_main_dec2012.jpg" alttext="Chef Olaf Niemeier"/>
<image url="http://food/dec2012/2_chutneys-from-hamburg_main_dec2012.jpg" alttext="Chef Olaf Niemeier"/>
</images>
</article>
<article articleid="81" title="Cat">
<thumb_image>
<image url="http://website/var/tmp/thumb_2220_1_itc-grand-chola-chennai_main_dec2012__forfeed.jpeg"/>
</thumb_image>
<images>
<image url="http://food/dec2012/1_chef-olaf-niemeier_main_dec2012.jpg" alttext="Chef Olaf Niemeier"/>
<image url="http://food/dec2012/2_chutneys-from-hamburg_main_dec2012.jpg" alttext="Chef Olaf Niemeier"/>
</images>
</article>
</Article>
</Category>
</Categories>
カテゴリ名と記事のタイトルを取得しました..しかし、画像を取得できませんでした..画像を取得するにはどうすればよいですか..plsは私を助けてくれます...
私は以下のコードを使用しました:
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
// reset
tempVal = "";
if (qName.equalsIgnoreCase("Category")) {
// create a new instance of Laptop
laptop = new Laptop();
laptop.setBrand(attributes.getValue("name"));
}
else if (qName.equalsIgnoreCase("article")) {
// create a new instance of Laptop
article = new Laptop();
article.setModel(attributes.getValue("title"));
}
else if (qName.equalsIgnoreCase("thumb_image")) {
// create a new instance of Laptop
image = new Laptop();
image.setImageURL(attributes.getValue("url"));
}
}
これらの解決策を教えてください... thum_imageタグだけから画像のURLを取得するにはどうすればよいですか...