Xml Parse : Xml « Development « Android






Xml Parse

     
//package com.helloandroid.acashboard.list;

import java.util.ArrayList;
import java.util.List;

import android.sax.Element;
import android.sax.EndElementListener;
import android.sax.EndTextElementListener;
import android.sax.RootElement;
import android.util.Xml;

public class XmlParseList {
//  TODO: do 1 function 2 folowing functon
//  parsing projects

  public List<String> parse(String XMLDOCUMENT,String root2,String itemname,String title,String title2) {
//    final Message currentMessage = new Message(); //TODO unused variable
    RootElement root = new RootElement(root2);
    final List<String> messages = new ArrayList<String>();
    final List<String> id = new ArrayList<String>();
    Element item = root.getChild(itemname);
    item.setEndElementListener(new EndElementListener() {
      public void end() {
        // documentd end listener!
      }
    });
    item.getChild(title).setEndTextElementListener(
        new EndTextElementListener() {
          public void end(String body) {
            // TODO GET CONTENT
            messages.add(body); //get name
          }
        });
    
    item.getChild(title2).setEndTextElementListener(
        new EndTextElementListener() {
          public void end(String body) {
            // TODO GET CONTENT
            messages.add(body); //get id
          }
        });
    
    try {
      Xml.parse(XMLDOCUMENT, root.getContentHandler());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    return messages;
  }
  

}

   
    
    
    
    
  








Related examples in the same category

1.Using xml resource
2.XML Resource Demo
3.Load style from styles.xml
4.Define PreferenceScreen in xml file
5.Using XML Parser
6.XML-defined adapters can be used to easily create adapters in your own application or to pass adapters to other processes.
7.Xml Serializer Uri
8.Get Text Content from Xml Node
9.Escape un escape Xml
10.Get Xml node value with substring
11.Get value from Element
12.Get attribute value
13.Get field from NamedNodeMap
14.get Node Value With Attribute
15.get Character Data From Element
16.update Xml