Posted By

noklpopl on 11/26/10


Tagged

xml parser android


Versions (?)

Android pull parser sample


 / Published in: Java
 

URL: http://www.nookl.com

  1. private void ParseConfigFile() throws XmlPullParserException, IOException
  2. {
  3. XmlResourceParser parser = getResources().getXml(R.xml.config);
  4. parser.next();
  5. int eventType = parser.getEventType();
  6. while (eventType != XmlPullParser.END_DOCUMENT)
  7. {
  8. if(eventType == XmlPullParser.START_DOCUMENT)
  9. {
  10. //stringBuffer.append("--- Start XML ---");
  11. }
  12. else if(eventType == XmlPullParser.START_TAG)
  13. {
  14. //stringBuffer.append("\nSTART_TAG: "+xpp.getName());
  15. }
  16. else if(eventType == XmlPullParser.END_TAG)
  17. {
  18. //stringBuffer.append("\nEND_TAG: "+xpp.getName());
  19. }
  20. else if(eventType == XmlPullParser.TEXT)
  21. {
  22. //stringBuffer.append("\nTEXT: "+xpp.getText());
  23. }
  24. eventType = parser.next();
  25. }
  26. parser.close();
  27. }

Report this snippet  

You need to login to post a comment.