public static void copyAttributes ( Element source , Map < String , String > dest ) { NamedNodeMap attributes = source . getAttributes ( ) ; if ( attributes != null ) { for ( int i = 0 ; i < attributes . getLength ( ) ; i ++ ) { Node attribute = attributes . item ( i ) ; dest . put ( attribute . getNodeName ( ) , attribute . getNodeValue ( ) ) ; } } }
Copy attributes from a DOM node to a map .