<doc> <element> <item> text1 </item> <item> text2 </item> </element> </doc> 

It is necessary to obtain the contents of the "element" tag along with the descendants using XmlPullParser. How to do it?

  • Congratulations. So what?))) - Gorets

1 answer 1

If parsing is not limited to XmlPullParser , then you can do it using JSoup .

If you need to get all the child elements of the element tag and they are all the same (as in the provided example), it is done like this:

 final String xmlDoc = "Ваш документ"; final Document doc = JSoup.parse(xmlDoc); final Elements items = doc.select("element>item"); String text; for (Element el: items) { text = el.text(); // Что то делаете с полученным текстом } 

About JSoup you can read here.