get Property Value from XML String - Android XML

Android examples for XML:XML String

Description

get Property Value from XML String

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        String xml = "java2s.com";
        String property = "java2s.com";
        System.out.println(getPropertyValue(xml, property));
    }// w  w  w  . j a v a  2  s . c  om

    public static String getPropertyValue(String xml, String property) {
        int index = xml.indexOf(property + "=");
        String value = null;
        if (index > 0) {
            index = xml.indexOf("\"", index) + 1;
            value = xml.substring(index, xml.indexOf("\"", index));
        }

        return value;
    }
}

Related Tutorials