StringUtils { public static String stripXmlTags(final String xml) { if (org.apache.commons.lang3.StringUtils.isBlank(xml)) { return xml; } String strippedXml = xml.replaceAll(XML_TAG_PATTERN, org.apache.commons.lang3.StringUtils.EMPTY); strippedXml = StringEscapeUtils.unescapeXml(strippedXml); strippedXml = org.apache.commons.lang3.StringUtils.trim(strippedXml); return strippedXml; }  static String stripXmlTags(final String xml);  }
@Test public void stripXmlTags() { assertNull(StringUtils.stripXmlTags(null)); assertNotSame("", org.remast.util.StringUtils.stripXmlTags(null)); assertEquals("", org.remast.util.StringUtils.stripXmlTags("")); assertEquals("<", org.remast.util.StringUtils.stripXmlTags("<")); assertEquals("<", org.remast.util.StringUtils.stripXmlTags("&lt;")); String htmlText = "<p>content</p>"; String text = "content"; assertEquals(text, org.remast.util.StringUtils.stripXmlTags(htmlText)); htmlText = "<html> " + "<body>" + "<p>content <i>Italic</i> and < b> bold</B>" + "</body>" + "</html>"; text = "content Italic and bold"; assertEquals(text, org.remast.util.StringUtils.stripXmlTags(htmlText)); }