Following is the xml content which i get after decrypting an encrypted value
<card order_no="1" id="cmpe0rhm3ym5ha8wlqp4jt7u" place="HOME">33</card>
Now i have the above content in a String called message.
Now i want parse the values such as id and place using the main tag "card" and the number "33" also to be parsed.
Following is what i have been tried
InputStream inputStream = new ByteArrayInputStream(message.getBytes());
XmlPullParser cardParser = Xml.newPullParser();
cardParser.setInput(inputStream, null);
Map<String, String> attrs = XMLParsers.getAttributes(cardParser);
String cardTag = cardParser.getName();
if (cardTag.equalsIgnoreCase("card"))
{
CardTag card = new CardTag();
card.setId(attrs.get("id"));
card.setPlace(attrs.get("place"));
card.setCardNumericValue(cardParser.getText());
return card;
}
I have stored the string in an InputStream and again tried to parse it, but i am getting a null pointer exception
Value of String cardTag seems to be null when i printed it. NullPointerException rises at if condition "if (cardTag.equalsIgnoreCase("card"))"
How to do this
No comments:
Post a Comment