Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9253437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:13:06+00:00 2026-06-18T11:13:06+00:00

I have to develop one android application. Its performs the attribute value is display

  • 0

I have to develop one android application.

Its performs the attribute value is display on listview…

This is my xml tags:

<root>
<Categories>
 <Category name="books">
 <Articles>
  <article articleid="170" title="Colour And Vibrancy Are Part Of Our DNA">
   <Description>
   Well-known interior designer
 </Description>

I have used below code:

  public class MainActivity extends Activity {

     String URL;
     static String KEY_CATEGORY = "Categories";
     ArrayList<HashMap<String, String>> songsList;
     static final String KEY_PNAME = "Category";
     static final String KEY_PRICE = "Description";
     static final String KEY_THUMB_URL = "thumb_image";

      ListAdapter adapter;

     /** Called when the activity is first created. */
     @Override
     protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        songsList = new ArrayList<HashMap<String, String>>();
  HorizontalListView list = (HorizontalListView) findViewById(R.id.listView1);

   adapter = new ListAdapter(this, songsList);
    list.setAdapter(adapter);

  URL="http://webservices/new_feed_articls.xml";

        XMLParser parser = new XMLParser();
        String xml = parser.getXmlFromUrl(URL); // getting XML from URL
        Document doc = parser.getDomElement(xml);// getting DOM element

        NodeList nl = doc.getElementsByTagName(KEY_CATEGORY);
        int numResults = parser.numResults(doc);

        if((numResults <= 0)){
            Toast.makeText(MainActivity.this, "There is no data in the xml file", Toast.LENGTH_LONG).show();
            finish();
        }


        // 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_PNAME,((Element)nl.item(i)).getAttribute("name"));


            map.put(KEY_PRICE, parser.getValue(e, KEY_PRICE));
              map.put(KEY_THUMB_URL, parser.getValue(e, KEY_THUMB_URL));

            // adding HashList to ArrayList
            songsList.add(map);
        }


        // Click event for single list row
        list.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                HashMap<String, String> map = songsList.get(position);

Here i have to run the app means the need to display category name on listview.How can i get the attribute value ??? please help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:13:07+00:00Added an answer on June 18, 2026 at 11:13 am

    I got the o/p after use below code:

    i have done the mistake in getElementsByTagName…

    Now i have changed the tag like:

    NodeList nl = doc.getElementsByTagName(KEY_PNAME);
    

    Now i have to run the output means am getting the attribute value well…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have develop one android application. Here i have to pass the value from
I have to develop one android application.The app is performs retrieve data from mysql
i have develop one android application. Here i have to set the tabbar bottom
I have to develop one android application. Here i have to develop grid view
I have to develop one android send mail use javamailapi application. message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(mercy.krishnaveni@gmail.com,demo@mercuryminds.com)); Using
Here i develop one android application and i have one image with size 197*253,
Hi i have to develop one android BBC_NEWS_READER application from here Here am getting
Hi i have develop an android application in which i want to prevent user
I occur a problem when develop a application on android. There have two image
I have developed a Android application with targetSdkVersion=15 . When I run this application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.