protected static String cleanXMLForMinHash ( final String xml ) { // Treat null and empty strings the same final String fixedXML = xml == null ? "" : xml ; String text = null ; try { final Document doc = XMLUtilities . convertStringToDocument ( fixedXML ) ; if ( doc != null ) { text = doc . getDocumentElement ( ) . getTextContent ( ) ; } } catch ( final Exception ex ) { // Do nothing } // the xml was invalid, so just strip out xml elements manually if ( text == null ) { text = fixedXML . replaceAll ( "</?.*?/?>" , " " ) ; } return text ; }
Cleans the provided XML by removing element names and other useless data .