Android XmlPullParser Value Get getPITarget(XmlPullParser pp)

Here you can find the source of getPITarget(XmlPullParser pp)

Description

Return PITarget from Processing Instruction (PI) as defined in XML 1.0 Section 2.6 Processing Instructions [16] PI ::= '<?'

License

Open Source License

Declaration

public static String getPITarget(XmlPullParser pp)
        throws IllegalStateException 

Method Source Code

//package com.java2s;
// for license please see accompanying LICENSE.txt file (available also at http://www.xmlpull.org/)

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

public class Main {
    /**/*from  www .  ja va  2s .  com*/
     * Return PITarget from Processing Instruction (PI) as defined in
     * XML 1.0 Section 2.6 Processing Instructions
     *  <code>[16] PI ::= '&lt;?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'</code>
     */
    public static String getPITarget(XmlPullParser pp)
            throws IllegalStateException {

        int eventType;
        try {
            eventType = pp.getEventType();
        } catch (XmlPullParserException ex) {
            // should never happen ...
            throw new IllegalStateException(
                    "could not determine parser state: " + ex
                            + pp.getPositionDescription());
        }
        if (eventType != XmlPullParser.PROCESSING_INSTRUCTION) {
            throw new IllegalStateException(
                    "parser must be on processing instruction and not "
                            + XmlPullParser.TYPES[eventType]
                            + pp.getPositionDescription());
        }
        final String PI = pp.getText();
        for (int i = 0; i < PI.length(); i++) {
            if (isS(PI.charAt(i))) {
                // assert i > 0
                return PI.substring(0, i);
            }
        }
        return PI;
    }

    /**
     * Return true if chacters is S as defined in XML 1.0
     * <code>S ::=  (#x20 | #x9 | #xD | #xA)+</code>
     */
    private static boolean isS(char ch) {

        return (ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t');
    }
}

Related

  1. getAttributes( XmlPullParser pullParser)
  2. getAttributes( XmlPullParser pullParser, String namespace, String elementName, String attributeName, String attributeValue)
  3. getPIData(XmlPullParser pp)
  4. getPIData(XmlPullParser pp)
  5. getPITarget(XmlPullParser pp)
  6. getRequiredAttributeValue(XmlPullParser pp, String namespace, String name)
  7. getRequiredAttributeValue(XmlPullParser pp, String namespace, String name)
  8. getValuesMap(XmlPullParser parser)
  9. loadFloatArrayByParser(XmlPullParser parser)