• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Get more than one attribute value on single android activity

krishnaveni

Well-Known Member
I have to fetch the attribute value and display it on Android listview.

This is my XML feed:
<Categories>
<Category name="books">
<Articles>
<article articleid="170" title="Colour And Vibrancy Are Part Of Our DNA">
<thumb_image>
<image url="http://website/var/tmp/thumb_2536_design_pavitra-rajaram_1_thumb_dec2012__forfeed.jpeg"/>
</thumb_image>
<images>
<image url="http://design/dec2012/1_pavitra-rajaram_1_main_dec2012.jpg" alttext="Pavitra Rajaram Interiors"/>
<image url="http://design/dec2012/4_pavitra-rajaram_4_main_dec2012.jpg" alttext="Pavitra Rajaram Interiors"/>

</Articles>
Here I have to fetch the article title and thumb_image URL on the same layout.

I have to run the app, which means all the image URLs are displayed from both images and thumb_image, but I need the URL from thumb_image alone.

I have used below code:

static String KEY_CATEGORY = "Articles";

static final String KEY_TITLE = "article";
static final String KEY_THUMB_URL = "image";

NodeList nl = doc.getElementsByTagName(KEY_THUMB_URL);

// looping through all song nodes &lt;song&gt;
for (int i = 0; i < nl.getLength(); i++) {
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
Element e = (Element) nl.item(i);
// adding each child node to HashMap key =&gt; value
map.put( KEY_TITLE,((Element)nl.item(i)).getAttribute("title"));
map.put( KEY_THUMB_URL,((Element)nl.item(i)).getAttribute("url"));

songsList.add(map);
}

How can I get the URL from thumb_image alone?
 
Back
Top Bottom