I have the following XML:
<ex>
<email>
[email protected]
</email>
<login_status>
TRUE
</login_status>
<category>
Personal
</category>
<subcategory>
Food
</subcategory>
<May>
50
</May>
</ex>
I have the following Java Code:
XmlPullParserFactory xmlFactoryObject = XmlPullParserFactory.newInstance();
XmlPullParser myParser = xmlFactoryObject.newPullParser();
myParser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
InputStream inputstream = new ByteArrayInputStream(response.getBytes());
myParser.setInput(inputstream, null);
int event;
String text = null;
try {
event = myParser.getEventType();
while (event != XmlPullParser.END_DOCUMENT) {
String name = myParser.getName();
switch (event) {
case XmlPullParser.START_TAG:
break;
case XmlPullParser.TEXT:
text = myParser.getText();
System.out.println("text"+text);
break;
case XmlPullParser.END_TAG:
String email = "email";
if(name.equals("email")){
email = myParser.getAttributeValue(null,"email");
System.out.println("emaildecrypt"+email);
}
break;
}
event = myParser.next();
}
// parsingComplete = false;
} catch (Exception e) {
e.printStackTrace();
}
However I am always getting Null when I print the email, I am following this tutorial but I am not able to determine where things go wrong? Any hints?