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

  • Home
  • SEARCH
  • 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 6378537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:01:17+00:00 2026-05-25T02:01:17+00:00

I am using the following code by the Android-people-XMLParsing example for parsing XML file

  • 0

I am using the following code by the Android-people-XMLParsing example for parsing XML file and it is working perfectly fine..

but it retrieve the data in TextView i want to put this data in a ListView..

I tried by creating CustomAdapter and by changing the Activity into the ListActivity..but nothing works..i can see only a blank screen..Can anyone help me to do this…

Thanks!!

     package com.androidpeople.xml.parsing;

     import java.net.URL;
     import javax.xml.parsers.SAXParser;
     import javax.xml.parsers.SAXParserFactory;
     import org.xml.sax.InputSource;
     import org.xml.sax.XMLReader;
     import android.app.Activity;
     import android.graphics.Color;
     import android.os.Bundle;
     import android.widget.LinearLayout;
     import android.widget.TextView;

    public class XMLParsingExample extends Activity {

/** Create Object For markerList Class */
mymarkers markerList =null;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    /** Create a new layout to display the view */
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(1);



    /** Create a new textview array to display the results */
    TextView name[];
    TextView address[];
    TextView city[];
    try {

        /** Handling XML */
        SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParser sp = spf.newSAXParser();
        XMLReader xr = sp.getXMLReader();

        /** Send URL to parse XML Tags */
        URL sourceUrl = new URL("xxxxxxxxx");

        /** Create handler to handle XML Tags ( extends DefaultHandler ) */
        MyXMLHandler myXMLHandler = new MyXMLHandler();
        xr.setContentHandler(myXMLHandler);
        xr.parse(new InputSource(sourceUrl.openStream()));

    } catch (Exception e) {
        System.out.println("XML Pasing Excpetion = " + e);
    }

    /** Get result from MyXMLHandler SitlesList Object */
    markerList = MyXMLHandler.markerList;

    /** Assign textview array lenght by arraylist size */


    name = new TextView[markerList.getName().size()];
    address = new TextView[markerList.getaddress().size()];
    city = new TextView[markerList.getCity().size()];
    /** Set the result text in textview and add it to layout */
    for (int i = 0; i < markerList.getName().size(); i++) {
        name[i] = new TextView(this);
        name[i].setText("Name = "+markerList.getName().get(i));

        address[i] = new TextView(this);
        address[i].setText("address = "+markerList.getaddress().get(i));

        city[i] = new TextView(this);  
        city[i].setText("city = "+markerList.getCity().get(i));
        System.out.println("count33..."+markerList.getCity().size());
        city[i].setBackgroundColor(Color.WHITE);
        layout.addView(name[i]);
        layout.addView(address[i]);
        layout.addView(city[i]);

        //layout.addView(border[i]);
    }

    /** Set the layout view to display */
    setContentView(layout);

}
}
  • 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-05-25T02:01:18+00:00Added an answer on May 25, 2026 at 2:01 am

    I’ve answered a very similar question few days back that you might want to check. You could check the question Android: Sax parsing to a listview and check the accepted answer. Follow the instruction until getView() part and you should be ok.

    In summary here is what you need to do:

    • Use DOM instead of SAX, it’s simpler and perfect for ListView
    • Implement an Adapter that extends BaseAdapter passing the root element to this adapter
    • Implement getView in the adapter to add the TextView that you want

    Again I’ve laid out the steps in the Android: Sax parsing to a listview. Let me know if you have any further questions

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

Sidebar

Related Questions

I am using the following code to display a video file in the android
I am able to retrieve all contacts from android in .vcf file using following
I am using the following code to blur an image in android, but it
Hi all I have created layout using following code <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I'm using the following code to query a database from my jsp, but I'd
I'm using the following code within the JCProperty class to retrieve data from a
I am using following code to open Android Contacts @Override public void onCreate(Bundle savedInstanceState)
friends, i am trying to check internetconnectivity in android and using following code final
i am using following code to setlistview adapter but giving me error at last
I'm using the following piece of code in Android to send a mail: Intent

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.