Get Node value and save to ArrayList
import java.util.ArrayList;
class Main {
public static ArrayList<String> getNodesValue(String xml, String nodeName) {
String[] nodesValue = null;
ArrayList<String> v = new ArrayList<String>();
while (xml.indexOf("<" + nodeName + ">") != -1) {
int start = xml.indexOf("<" + nodeName + ">")
+ ("<" + nodeName + ">").length();
int stop = xml.indexOf("</" + nodeName + ">");
String tmp = xml.substring(start, stop);
v.add(tmp);
xml = xml.substring((stop + ("</" + nodeName + ">").length()));
}
return v;
}
}
Related examples in the same category