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