Get Xml node value with substring
class Main{
public static String getNodeValue(String XML, String nodeName){
String tokenValue = null;
int start = XML.indexOf("<"+nodeName+">") + ("<"+nodeName+">").length();
int stop = XML.indexOf("</"+nodeName+">");
if(start>stop || stop<0) return "";
try{
tokenValue = XML.substring(start, stop);
}catch (Exception ex){
ex.printStackTrace();
}
return tokenValue;
}
}
Related examples in the same category