get Element Value from Element String - Android XML

Android examples for XML:XML Element

Description

get Element Value from Element String

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        String element = "java2s.com";
        System.out.println(getElementValue(element));
    }//w  ww. jav a  2s .co m

    public static String getElementValue(String element) {
        int startIndex = element.indexOf('>') + 1;
        int endIndex = element.indexOf("</");
        return element.substring(startIndex, endIndex);
    }
}

Related Tutorials