List of usage examples for com.liferay.portal.kernel.util HtmlUtil stripBetween
public static String stripBetween(String text, String tag)
From source file:com.liferay.randombibleverse.util.VerseWebCacheItem.java
License:Open Source License
private Verse _getBiblegateway(Verse verse) throws Exception { StringBundler sb = new StringBundler(); sb.append("http://www.biblegateway.com/passage/?search="); sb.append(HttpUtil.encodeURL(_location)); sb.append("&version="); sb.append(_versionId);//from w w w . ja v a2 s . c o m String text = HttpUtil.URLtoString(sb.toString()); int x = text.indexOf("result-text-style"); x = text.indexOf(">", x); int y = text.indexOf("</div>", x); text = text.substring(x + 1, y); y = text.indexOf("Footnotes:"); if (y != -1) { text = text.substring(0, y); } else { y = text.indexOf("Cross references:"); if (y != -1) { text = text.substring(0, y); } } // Strip everything between <span> and </span> text = HtmlUtil.stripBetween(text, "span"); // Strip everything between <sup> and </sup> text = HtmlUtil.stripBetween(text, "sup"); // Strip everything between <h4> and </h4> text = HtmlUtil.stripBetween(text, "h4"); // Strip everything between <h5> and </h5> text = HtmlUtil.stripBetween(text, "h5"); // Strip HTML text = HtmlUtil.stripHtml(text).trim(); // Strip text = StringUtil.replace(text, " ", ""); // Strip carriage returns text = StringUtil.replace(text, "\n", ""); // Strip double spaces while (text.indexOf(" ") != -1) { text = StringUtil.replace(text, " ", " "); } // Replace " with " text = StringUtil.replace(text, "\"", """); // Trim text = text.trim(); return new Verse(_location, text); }