I understand the difference between how the SAX parser works vs the XMLPull parser. In fact there\'s a pretty good explanation here:
http://www.firstobject.com/xml-r
I found better and more efficient output while using SAX rather than XMLPullParser... My scenario is to parse the attributes under a XML tag, i could do it easily and insert it into Database smoothly... I think it depends on situations, when i need to write on a XML file i prefer DOM Parser...
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
currentElement = true;
db = new DatabaseHelper(thecontext);
if (qName.equals("Asa.Amms.Data.Entity.User")) {
int length = attributes.getLength();
for (int i = 0; i < length; i++) {
String name = attributes.getQName(i);
if (name.equals("Id")) {
id = Integer.parseInt(attributes.getValue(i));
}
if (name.equals("Login")) {
LoginID = attributes.getValue(i).toString();
}
if (name.equals("Name")) {
Name = attributes.getValue(i).toString();
}
if (name.equals("Password")) {
Password = attributes.getValue(i).toString();
}
if (name.equals("ProgramOfficerId")) {
user_ProgramOfficerId = Integer.parseInt(attributes.getValue(i).toString());
}
}
Log.i("Baal dhukbe", id + LoginID + Name + Password);
db.insertUser(id, LoginID, Name, Password, user_ProgramOfficerId);
}
}