Parsing XML using Android XmlPullParser

pas7hxyu

New Member
I am having problem pulling data using Android XmlPullParser.Main problem is caused by XML format being too simple which I can't change.I only need a value of c1 (value of c is a fixed value, but c1 is not)\[code\]<map><entry><string>a</string><string>a1</string></entry><entry><string>b</string><string>b1</string></entry><entry><string>c</string> <string>c1</string> ----this value is what I need----</entry><entry><string>d</string><string>d1</string></entry></map>\[/code\]How can I match string == C and read the next string value which is C1 by modifying code below? In other words, wordOut.SetText(C1) is what I want.\[code\]while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG) { if (xpp.getName().equals("map")) { insideItem = true; } else if (xpp.getName().equals("string")) { if (insideItem) { wordOut.setText(xpp.nextText()); } } }else if(eventType==XmlPullParser.END_TAG && xpp.getName().equals("map")){ insideItem=false; }eventType = xpp.next(); //move to next element\[/code\]Thanks for the help in advance!!!
 
Back
Top