Here you can find the source of ReadSubtreeString(XmlPullParser reader)
public static String ReadSubtreeString(XmlPullParser reader) throws XmlPullParserException, IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; public class Main { public static String ReadSubtreeString(XmlPullParser reader) throws XmlPullParserException, IOException { if (reader == null) throw new NullPointerException(); // Return if not on a start element tag if (reader.getEventType() != XmlPullParser.START_TAG) return ""; StringBuilder builder = new StringBuilder(); int depth = GetDepth(reader); while (GetDepth(reader) != depth || reader.getEventType() != XmlPullParser.END_TAG) { reader.next();/*w w w .j a va 2 s. c om*/ if (reader.getEventType() != XmlPullParser.END_TAG) { if (reader.getEventType() == XmlPullParser.ENTITY_REF || reader.getEventType() == XmlPullParser.CDSECT || reader.getEventType() == XmlPullParser.TEXT) { builder.append(reader.getText()); } } } return builder.toString(); } public static int GetDepth(XmlPullParser reader) { if (reader == null) throw new NullPointerException(); return Math.max(reader.getDepth() - 1, 0); } }