Android XmlPullParser Read readText(XmlPullParser parser)

Here you can find the source of readText(XmlPullParser parser)

Description

read Text

Declaration

private static String readText(XmlPullParser parser)
            throws XmlPullParserException, IOException 

Method Source Code

//package com.java2s;
import java.io.IOException;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

public class Main {
    private static String readText(XmlPullParser parser)
            throws XmlPullParserException, IOException {
        String value = null;//from   w  w w.j a va 2  s .  co m

        while (parser.next() != XmlPullParser.END_TAG) {
            if (parser.getEventType() == XmlPullParser.END_DOCUMENT) {
                throw new XmlPullParserException(
                        "reached unexpected end of document");
            } else if (parser.getEventType() != XmlPullParser.TEXT) {
                continue;
            }
            String text = parser.getText();

            value = textOf(text);
        }

        return value;
    }

    private static String textOf(String text) {
        return text.trim().replace("\r", "");
    }
}

Related

  1. readLongAttribute(XmlPullParser in, String name, long defaultValue)
  2. readNumber(XmlPullParser parser)
  3. readString(XmlPullParser parser, String ns, String tag)
  4. readStringArray(XmlPullParser parser, String tagName, String delimiter)
  5. readStringAttribute(XmlPullParser in, String name)
  6. readText(XmlPullParser parser)
  7. readText(XmlPullParser parser)
  8. readText(XmlPullParser parser)
  9. readText(XmlPullParser parser, String tagName)