Friday, September 30, 2011

[android-developers] Re: XML DOM Parser works in JAVA, Crashes Android App, Now XMLPullParser

So I'm starting to suspect my XML file. Here it is:

<?xml version="1.0" encoding="UTF-8"?>




I rewrote the method to use a XML pull parser:

public void parseCharXmlFile(){
Chars myCh = null;
String nameTag= "";

try {
InputStream iStrm = getResources().openRawResource(R.xml.chars);
XmlPullParser parser = Xml.newPullParser();
parser.setInput(iStrm, null);
int eventType = parser.getEventType();
boolean done = false;

while (eventType != XmlPullParser.END_DOCUMENT ){
switch (eventType){
case XmlPullParser.START_DOCUMENT:
case XmlPullParser.START_TAG:
nameTag = parser.getName();
if (nameTag.equalsIgnoreCase("ch") ) {
}else if (nameTag.equalsIgnoreCase("count")) {
} // event switch end
eventType =;
} catch (Exception e) {
throw new RuntimeException(e);


Every thing that I've read indicate that this should work. Any
thoughts would be appreciated.


You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment