public static String prettyPrintElementLocally ( Element e ) { final ImmutableMap . Builder < String , String > ret = ImmutableMap . builder ( ) ; final NamedNodeMap attributes = e . getAttributes ( ) ; for ( int i = 0 ; i < attributes . getLength ( ) ; ++ i ) { final Node attr = attributes . item ( i ) ; ret . put ( attr . getNodeName ( ) , "\"" + attr . getNodeValue ( ) + "\"" ) ; } return "<" + e . getNodeName ( ) + " " + Joiner . on ( " " ) . withKeyValueSeparator ( "=" ) . join ( ret . build ( ) ) + "/>" ; }
A human - consumable string representation of an element with its attributes but without its children . Do not depend on the particular form of this .