public static void para(Node dom) {
Node pNode = dom.getFirstChild();
if( pNode.hasChildNodes() ){
Node child = pNode.getFirstChild();
if( child != null ){
if( (child.getNodeType() == Node.TEXT_NODE)
&&
((Text) child).getWholeText().trim().equals("")
){
pNode.removeChild( child );
} } }
if( pNode.hasChildNodes() ){
Node child = pNode.getLastChild();
if( child != null ){
if( (child.getNodeType() == Node.TEXT_NODE)
&&
((Text) child).getWholeText().trim().equals("")
){
pNode.removeChild( child );
} } }
if( pNode.hasChildNodes() ){
Node child = pNode.getFirstChild();
if( (child != null)
&& (child.getNextSibling() == null)
&& (child.getNodeType() == Node.TEXT_NODE)
){
String txt = ((Text) child).getWholeText();
String trm = txt.trim();
if( !trm.equals(txt) ){
((Text)child).replaceWholeText(trm);
} } }
}
-_-_-