private static String collapseNode ( String xml , String name ) { String answer = xml ; Pattern pattern = Pattern . compile ( "<" + name + "(.*)></" + name + ">" ) ; Matcher matcher = pattern . matcher ( answer ) ; if ( matcher . find ( ) ) { answer = matcher . replaceAll ( "<" + name + "$1/>" ) ; } return answer ; }
Collapses all the named node in the XML