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 6129909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:47:49+00:00 2026-05-23T16:47:49+00:00

Can anyone give me a full tutorial series Link or sample eclipse project code

  • 0

Can anyone give me a full tutorial series Link or sample eclipse project code Link for displaying data in list view after SAX Parsing of XML in Android.

Thanks in advance.

  • 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-23T16:47:50+00:00Added an answer on May 23, 2026 at 4:47 pm

    Here try this

    In the activity you want the listView to be in:

    public class listView extends ListActivity {
        ArrayList<String> items = new ArrayList<String>();
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.listViewLayout);
            try {
                /** Handling XML */
                SAXParserFactory spf = SAXParserFactory.newInstance();
                SAXParser sp = spf.newSAXParser();
                XMLReader xr = sp.getXMLReader();
    
                /** If using remote server for xml file */
                URL sourceUrl = new URL("http://www.server.com/fileToParse.xml");
    
                /** Create handler to handle XML Tags ( extends DefaultHandler ) */
                ExampleHandler myXMLHandler = new ExampleHandler();
                xr.setContentHandler(myXMLHandler);
                /** if using remote file */
                xr.parse(new InputSource(sourceUrl.openStream()));
                /** if local file */
                xr.parse(new InputSource(getContext().getResources().getXml(R.fileToParse.MyXml));
            }catch(Exception e) {
                Log.e("XML Error "+e.toString());
            }
    
            /** Get result from MyXMLHandler SitlesList Object */
            sitesList = ExampleHandler.sitesList;
            for(int i = 0; i < sitesList.getName().size(); i++) {
                items.add(sitesList.getName().get(i)+" "+sitesList.getLastName().get(i));
            }
    
            /** Set the layout view to display */
            setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items));
        }
    
        public void onListItemClick(ListView parent, View v, int position, long id) {
            /** puExtra method for if you want to pass variable to next activity */
            Intent i = new Intent(this, listViewSub.class);
            i.putExtra("name", sitesList.getName());
            startActivity(i);
        }
    }
    

    listViewLayout.xml:
    Can’t get layout file to show so click here

    ExampleHandler.java:

    public class ExampleHandler extends DefaultHandler{
    
        Boolean currentElement = false;
        String currentValue = null;
        public static SitesList sitesList = null;
    
        public static SitesList getSitesList() {
        return sitesList;
        }
    
        public static void setSitesList(SitesList sitesList) {
        ExampleHandler.sitesList = sitesList;
        }
    
        /** Called when tag starts ( ex:- <name>AndroidPeople</name>
        * -- <name> )*/
        @Override
        public void startElement(String uri, String localName, String qName,
        Attributes attributes) throws SAXException {
    
        currentElement = true;
    
        if (localName.equals("Records"))
        {
        /** Start */
        sitesList = new SitesList();
        }
    
        }
    
        /** Called when tag closing ( ex:- <name>AndroidPeople</name>
        * -- </name> )*/
        @Override
        public void endElement(String uri, String localName, String qName)
        throws SAXException {
    
        currentElement = false;
    
        /** set value */
        if (localName.equalsIgnoreCase("FirstName"))
        sitesList.setName(currentValue);
        else if(localName.equalsIgnoreCase("LastName"))
        sitesList.setLastName(currentValue);
        }   
    
        /** Called to get tag characters ( ex:- <name>AndroidPeople</name>
        * -- to get AndroidPeople Character ) */
        @Override
        public void characters(char[] ch, int start, int length)
        throws SAXException {
    
        if (currentElement) {
        currentValue = new String(ch, start, length);
        currentElement = false;
        }
    
        }
    }
    

    SitesList.java:

    public class SitesList {
    
    /** Variables */
    private ArrayList<String> name = new ArrayList<String>();
    private ArrayList<String> lastName = new ArrayList<String>();
    
    /** In Setter method default it will return arraylist
    * change that to add */
    
    public ArrayList<String> getName() {
    return name;
    }
    
    public void setName(String name) {
    this.name.add(name);
    }
    
    public void setLastName(String lastName) {
        this.lastName.add(lastName);
    }
    
    public ArrayList<String> getLastName() {
        return lastName;
    }
    
    }
    

    fileToParse.xml: Click here for xml file

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

Sidebar

Related Questions

Can anyone give me a complete list of string manipulation function in Microsoft SQL
Can anyone give an example or a link to an example which uses __builtin_prefetch
Can anyone give me pointers to good books or web sites that teach how
Can anyone give me details of runtime error 3734 in Access vba. For reference
Can anyone give a concise set of real-world considerations that would drive the choice
Can anyone give me a scenario where they think busy cursors are justified? I
Can anyone give me an idea how can we show or embed a YouTube
Can anyone give an idea of how should I implement undo/redo of cutting/copying/pasting of
Can anyone give me a hand with a touch of regex? I'm reading in
Can anyone give me an example of how I can consume the following web

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.