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