Android XML Parse parseTagValue(String xml, String tag, String endTag)

Here you can find the source of parseTagValue(String xml, String tag, String endTag)

Description

This method parse the xml tag value.

License

Apache License

Parameter

Parameter Description
xml a parameter
tag a parameter
endTag a parameter

Declaration

public static String parseTagValue(String xml, String tag, String endTag) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//from   w w  w  .  java 2 s  .co  m
     * This method parse the xml tag value.
     * 
     * @param xml
     * @param tag
     * @param endTag
     * @return
     */
    public static String parseTagValue(String xml, String tag, String endTag) {
        String val = "";
        try {
            int index1 = xml.indexOf(tag) + tag.length();
            int index2 = xml.indexOf(endTag, index1);
            if (index1 > -1 && index2 > -1) {
                val = xml.substring(index1, index2);
            }
        } catch (Throwable thrown) {
            val = null;
        }
        return val;
    }
}

Related

  1. parse(File source)
  2. parse(String source)
  3. parse(String xml)
  4. parse(String xmlstr, Class clazz, List fields, List elements, String itemElement)
  5. parseResponse(HttpResponse response)
  6. ReadCityCode(Context context, String cityname)
  7. XMLfromString(String xml)