Java tutorial
//package com.java2s; public class Main { public static String findTag(String tagName, StringBuffer result) { String search = result.toString(); String startTag = "<" + tagName + ">"; String endTag = "</" + tagName + ">"; int start = search.indexOf(startTag); int end = search.indexOf(endTag); if (start == -1 || end == -1) { return null; } String val = search.substring(start + startTag.length(), end); result.delete(0, end + endTag.length()); return val; } }