private String getStringValue ( Node node ) { switch ( node . getNodeType ( ) ) { case Node . ATTRIBUTE_NODE : case Node . TEXT_NODE : return node . getNodeValue ( ) ; default : { try { Transformer transformer = TRANSFORMER_FACTORY . newTransformer ( ) ; StringWriter buffer = new StringWriter ( ) ; transformer . setOutputProperty ( OutputKeys . OMIT_XML_DECLARATION , "yes" ) ; transformer . transform ( new DOMSource ( node ) , new StreamResult ( buffer ) ) ; return buffer . toString ( ) ; } catch ( Exception e ) { } return null ; } } }
Returns the string value for the node