Android pull parser sample


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }

URL: http://www.nookl.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.