Java tutorial
//package com.java2s; import java.util.Vector; public class Main { private static Vector<String> getSubTag(String source, String tag) { Vector<String> sSubTag = new Vector<String>(); if (source == null || source.isEmpty() || tag == null || tag.isEmpty()) return sSubTag; String subString, sTemp; int start, end; subString = source; sTemp = "<" + tag; start = subString.indexOf(sTemp); while (start >= 0) { subString = subString.substring(start); sTemp = "/>"; end = subString.indexOf(sTemp); if (end < 0) break; end += sTemp.length(); sSubTag.add(subString.substring(0, end)); subString = subString.substring(end); sTemp = "<" + tag; start = subString.indexOf(sTemp); } return sSubTag; } }