I am using XmlPullParser for xml parsing in my android app but when I set input as InputStream it not works while I set input as Reader it starts working
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput(obj,null);//obj is the object of InputStream
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
logger.println("eventType.."+eventType);
if(eventType == XmlPullParser.START_DOCUMENT) {
// control goes here only
} else if(eventType == XmlPullParser.START_TAG) {
//This block never executed
}
} else if(eventType == XmlPullParser.END_TAG) {
//This block never executed
} else if(eventType == XmlPullParser.TEXT) {
}
eventType = xpp.next();
}
Even if I store data from InputStream object in a string and set that String as input then this code also works fine.
xpp.setInput(new StringReader(str));//str contains the data from InputStream
<?xml version="1.0" encoding="UTF-8" ?>
" part) in your document look like? – Bootedobj
? – Hakefactory.setNamespaceAware(true);
and see if that helps... – Hake