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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:10:26+00:00 2026-06-10T03:10:26+00:00

Im trying to code an android RSS reader that will (for now) parse the

  • 0

Im trying to code an android RSS reader that will (for now) parse the xml from this MangaPanda List. I’m using this Android XML example for basic structure (and because it uses XMLPullParser) as well as this example because of its clear explanation of its EfficientAdapter, AsyncTask, and ListView usage.

So far I think I’ve “merged” the two pretty well but I cant quite figure out how to properly execute the parsing process.

My question is: How would I properly implement the LoadXmlFromNetwork() so that it would return the proper format for my adapter?

MainActivity:

  //Implementation of AsyncTask used to download XML feed from stackoverflow.com.
private class loadingTask extends AsyncTask<String, Void, String> {
 @Override
 protected String doInBackground(String... urls) {
     try {
         return loadXmlFromNetwork(urls[0]);
     } catch (IOException e) {
         return getResources().getString(R.string.hello_world);
     } catch (XmlPullParserException e) {
         return getResources().getString(R.string.menu_settings);
     }
 }

 @Override
 protected void onPostExecute(String result) {  
     setContentView(R.layout.activity_main);
     // Displays the HTML string in the UI via a WebView
     listview1.setAdapter(new EfficientAdapter(MainActivity.this, Manga));
     ShowProgress.dismiss();
 }

}

public Manga loadXmlFromNetwork(String urlString) throws XmlPullParserException, IOException {
    InputStream stream = null;
    // Instantiate the parser
    MainParser MainParser = new MainParser();
    List<Manga> mangas = null;
    String mangaAlpha = null;
    String mangaName = null;
    boolean mangaComplete = false;


    try {
        stream = downloadUrl(urlString);        
        mangas = MainParser.parse(stream);
    // Makes sure that the InputStream is closed after the app is
    // finished using it.
    } finally {
        if (stream != null) {
            stream.close();
        } 
     }

    // StackOverflowXmlParser returns a List (called "entries") of Entry objects.
    // Each Entry object represents a single post in the XML feed.
    // This section processes the entries list to combine each entry with HTML markup.
    // Each entry is displayed in the UI as a link that optionally includes
    // a text summary.

    return mangas;
}
 // Given a string representation of a URL, sets up a connection and gets
 // an input stream.
 private InputStream downloadUrl(String urlString) throws IOException {
     URL url = new URL(urlString);
     HttpURLConnection conn = (HttpURLConnection) url.openConnection();
     conn.setReadTimeout(10000 /* milliseconds */);
     conn.setConnectTimeout(15000 /* milliseconds */);
     conn.setRequestMethod("GET");
     conn.setDoInput(true);
     // Starts the query
     conn.connect();
     InputStream stream = conn.getInputStream();
    return stream;      
 }


}

MainParser:

public class MainParser {

// We don't use namespaces
private static final String ns = null;

public List<Manga> parse(InputStream in) throws XmlPullParserException, IOException {
    try {
        XmlPullParser parser = Xml.newPullParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
        parser.setInput(in, null);
        parser.nextTag();
        return readFeed(parser);
    } finally {
        in.close();
    }
}

private List<Manga> readFeed(XmlPullParser parser) throws XmlPullParserException, IOException {
    List<Manga> mangas = new ArrayList<Manga>();

    parser.require(XmlPullParser.START_TAG, ns, "feed");
    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();
        // Starts by looking for the entry tag
        if (name.equals("li")) {
            mangas.add(readTag(parser));
        } else {
            skip(parser);
        }
    }  
    return mangas;
}

private Manga readTag(XmlPullParser parser) throws XmlPullParserException, IOException {
    parser.require(XmlPullParser.START_TAG, ns, "li");
    String mangaAlpha =null;
    String mangaName = null;
    String mangaLink = null;
    boolean mangaComplete = false;

    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();
        if (name.equals("a")) {
            mangaAlpha = parser.getAttributeValue(null, "name");
        } else if (name.equals("a")) {
            mangaName = parser.getText();
        } else if (name.equals("a")) {
            mangaLink = parser.getAttributeValue(null, "href");
        } else if (name.equals("span")) {
            mangaComplete = true;
        } else {
            skip(parser);
        }
    }
    return new Manga(mangaAlpha, mangaName, mangaLink, mangaComplete);
}

private void skip(XmlPullParser parser) throws XmlPullParserException, IOException {
    if (parser.getEventType() != XmlPullParser.START_TAG) {
        throw new IllegalStateException();
    }
    int depth = 1;
    while (depth != 0) {
        switch (parser.next()) {
        case XmlPullParser.END_TAG:
            depth--;
            break;
        case XmlPullParser.START_TAG:
            depth++;
            break;
        }
    }
 }

}

My EfficientAdapter:

public class EfficientAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<Manga> mangadata;
private static LayoutInflater inflater = null;
//public ImageLoader imageLoader;
ViewHolder holder;

EfficientAdapter(Activity a, ArrayList<Manga> d) {

    activity = a;
    mangadata = d;
    inflater = (LayoutInflater) activity
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    //imageLoader = new ImageLoader(activity.getApplicationContext());

}

@Override
public int getCount() {
    return mangadata.toArray().length;

}

@Override
public Object getItem(int position) {

    return position;
}

@Override
public long getItemId(int position) {

    return position;
}

public static class ViewHolder {
    public TextView label;
    public TextView addr;
    //public ImageView image;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View vi = convertView;

    if (convertView == null) {
        vi = inflater.inflate(R.layout.textholder, null);
        holder = new ViewHolder();
        holder.label = (TextView) vi.findViewById(R.id.textView1);
        holder.addr = (TextView) vi.findViewById(R.id.textView2);
        //holder.image = (ImageView) vi.findViewById(R.id.icon);
        vi.setTag(holder);
    } else
        holder = (ViewHolder) vi.getTag();

    holder.label.setText(mangadata.get(position).getMangaAlpha());
    holder.addr.setText(mangadata.get(position).getMangaName());

    //imageLoader.DisplayImage((data.get(position).getThumbnail()), activity,
    //      holder.image, 72, 72);

    return vi;
}

}

On a side note: I didn’t know how much of my code would be necessary to properly explain my problem so please feel free to edit out unnecessary parts.

  • 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-10T03:10:27+00:00Added an answer on June 10, 2026 at 3:10 am

    Change your asynctask like that:

    private class loadingTask extends AsyncTask<String, Void, List<Manga>> {
        @Override
        protected String doInBackground(String... urls) {
            try {
                return loadXmlFromNetwork(urls[0]);
            } catch (IOException e) {
                return null;
            } catch (XmlPullParserException e) {
                return null;
            }
        }
    
        @Override
        protected void onPostExecute(List<Manga> result) {  
            setContentView(R.layout.activity_main);
            // Displays the HTML string in the UI via a WebView
            listview1.setAdapter(new EfficientAdapter(MainActivity.this, result));
            ShowProgress.dismiss();
        }
    }
    
    public List<Manga> loadXmlFromNetwork(String urlString) throws XmlPullParserException, IOException {
    
    ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this code for on android just trying to convert string to
I'm trying to parse the getprop command of android. Here's the code I'm using.
I´m trying to use spring android to parse an xml that looks like that
I am using Android 2.2. I am trying following code to run: Uri uri=Uri.parse(http://bluediamondring-s.com/wp-content/uploads/2010/08/gold-ring.jpg);
I am trying to run this code in android using eclips IDE. int maxrow=0;
I'm trying to write a java code on an Android emulator that will send
Im trying to make a Manga Rss-Reader app using the XmlPullParser that was used
I have been trying to parse this ( http://app.calvaryccm.com/mobile/android/v1/devos ) URL using a SAX
I am a Student..and right now trying to develop code for android..that shows nearby
I'm trying to upload a file from Android (2.3.4) using the below code, I

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.