1. Check out our companion app, Forums for Android! Download from Google Play

xml parsing listview in android like category,subcategory

Discussion in 'Application Development' started by krishnaveni, Dec 26, 2012.

  1. krishnaveni

    krishnaveni Well-Known Member
    Thread Starter

    Dec 16, 2011
    i have to develop android listview using xml parsing., This is my xml feed:http://dev.mercuryminds.com/xctesting/feed.xml

    Am getting xml feed from my mysql server.

    The product is added day to day.so how can i develop these.

    Here i need 3 kind of listview:

    1st view: Category
    2nd view: SubCategory
    3rd view: Product

    In 1st view have to display Categoryname alone.

    In 2nd view:

    have to display subcategoryname belongs to Categoryname.

    In 3nd View:

    Have to display Product name and price belongs to subcategoryname.

    This is my 1st view code:

    public class MainActivity extends Activity {
    static final String URL = "http://dev.mercuryminds.com/xctesting/feed.xml";

    static String KEY_CATEGORY = "Category";
    static final String KEY_TITLE = "Categoryname";

    ListView lview3;
    LazyAdapter adapter;
    public void onCreate(Bundle savedInstanceState) {
    final ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>();
    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);

    // 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);

    map.put(KEY_TITLE, parser.getValue(e, KEY_TITLE));

    lview3 = (ListView) findViewById(R.id.listView1);
    adapter = new LazyAdapter(this, songsList);

    lview3.setOnItemClickListener(new OnItemClickListener() {

    public void onItemClick(AdapterView<?> parent, View view,
    int position, long id) {




    How can i develop 2nd view and 3rd view.please give me solution for me..


Share This Page