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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:28:15+00:00 2026-06-04T15:28:15+00:00

Hello I am in the process of making an Android app that pulls some

  • 0

Hello I am in the process of making an Android app that pulls some data from a Wiki, at first I was planning on finding a way to parse the HTML, but from something that someone pointed out to me is that XML would be much easier to work with. Now I am stuck trying to find a way to parse the XML correctly. I am trying to parse from a web address right now from:

http://zelda.wikia.com/api.php?action=query&list=categorymembers&cmtitle=Category:Games&cmlimit=500&format=xml

I am trying to get the titles of each of the games into a string array and I am having some trouble. I don’t have an example of the code I was trying out, it was by using xmlpullparser. My app crashes everytime that I try to do anything with it. Would it be better to save the XML locally and parse from there? or would I be okay going from the web address? and how would I go about parsing this correctly into a string array? Please help me, and thank you for taking the time to read this.

If you need to see code or anything I can get it later tonight, I am just not near my PC at this time. Thank you.

  • 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-04T15:28:16+00:00Added an answer on June 4, 2026 at 3:28 pm

    Whenever you find yourself writing parser code for simple formats like the one in your example you’re almost always doing something wrong and not using a suitable framework.

    For instance – there’s a set of simple helpers for parsing XML in the android.sax package included in the SDK and it just happens that the example you posted could be easily parsed like this:

    public class WikiParser {
        public static class Cm {
            public String mPageId;
            public String mNs;
            public String mTitle;
        }
        private static class CmListener implements StartElementListener {
            final List<Cm> mCms;
            CmListener(List<Cm> cms) {
                mCms = cms;
            }
            @Override
            public void start(Attributes attributes) {
                Cm cm = new Cm();
                cm.mPageId = attributes.getValue("", "pageid");
                cm.mNs = attributes.getValue("", "ns");
                cm.mTitle = attributes.getValue("", "title");
                mCms.add(cm);
            }
        }
        public void parseInto(URL url, List<Cm> cms) throws IOException, SAXException {
            HttpURLConnection con = (HttpURLConnection) url.openConnection();
            try {
                parseInto(new BufferedInputStream(con.getInputStream()), cms);
            } finally {
                con.disconnect();
            }
        }
        public void parseInto(InputStream docStream, List<Cm> cms) throws IOException, SAXException {
            RootElement api = new RootElement("api");
            Element query = api.requireChild("query");
            Element categoryMembers = query.requireChild("categorymembers");
            Element cm = categoryMembers.requireChild("cm");
            cm.setStartElementListener(new CmListener(cms));
            Xml.parse(docStream, Encoding.UTF_8, api.getContentHandler());
        }
    }
    

    Basically, called like this:

    WikiParser p = new WikiParser();
    ArrayList<WikiParser.Cm> res = new ArrayList<WikiParser.Cm>();
    try {
        p.parseInto(new URL("http://zelda.wikia.com/api.php?action=query&list=categorymembers&cmtitle=Category:Games&cmlimit=500&format=xml"), res);
    } catch (MalformedURLException e) {
    } catch (IOException e) {
    } catch (SAXException e) {}
    

    Edit: This is how you’d create a List<String> instead:

    public class WikiParser {
        private static class CmListener implements StartElementListener {
            final List<String> mTitles;
            CmListener(List<String> titles) {
                mTitles = titles;
            }
            @Override
            public void start(Attributes attributes) {
                String title = attributes.getValue("", "title");
                if (!TextUtils.isEmpty(title)) {
                    mTitles.add(title);
                }
            }
        }
        public void parseInto(URL url, List<String> titles) throws IOException, SAXException {
            HttpURLConnection con = (HttpURLConnection) url.openConnection();
            try {
                parseInto(new BufferedInputStream(con.getInputStream()), titles);
            } finally {
                con.disconnect();
            }
        }
        public void parseInto(InputStream docStream, List<String> titles) throws IOException, SAXException {
            RootElement api = new RootElement("api");
            Element query = api.requireChild("query");
            Element categoryMembers = query.requireChild("categorymembers");
            Element cm = categoryMembers.requireChild("cm");
            cm.setStartElementListener(new CmListener(titles));
            Xml.parse(docStream, Encoding.UTF_8, api.getContentHandler());
        }
    }
    

    and then:

    WikiParser p = new WikiParser();
    ArrayList<String> titles = new ArrayList<String>();
    try {
        p.parseInto(new URL("http://zelda.wikia.com/api.php?action=query&list=categorymembers&cmtitle=Category:Games&cmlimit=500&format=xml"), titles);
    } catch (MalformedURLException e) {
    } catch (IOException e) {
    } catch (SAXException e) {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello i want to know if i can download my app before making it
Hello I am new to facebook app development and working over my first app.
Hello StackOverflow, I have an ASP.NET/C# webpage that calls functions from a managed .dll
Hello guys i'm making a little app in which i need to enumerate all
Hello, Im working on a solution for Android that will record calls (both out
Hello Is there a way to host something like a SQL server process within
I am using MATLAB to process data from files. I am writing a program
Hello I am trying to take a date input from jquery UI and process
Hello I am trying to figure out how to get data from my worker
Hello i am making a code for doing some editing on mp4 video using

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.