public static void setElementContent ( final Node n , final String s ) throws SAXException { NodeList children = n . getChildNodes ( ) ; for ( int i = 0 ; i < children . getLength ( ) ; i ++ ) { Node curnode = children . item ( i ) ; n . removeChild ( curnode ) ; } Document d = n . getOwnerDocument ( ) ; final Node textNode = d . createTextNode ( s ) ; n . appendChild ( textNode ) ; }
Replace the content for the current element .