public static String newTag ( final String tagname , final String value , final Map < String , String > attributes ) { final StringBuilder xmlTag = new StringBuilder ( ) ; xmlTag . append ( "<" ) . append ( tagname ) ; if ( attributes != null && ! attributes . isEmpty ( ) ) { xmlTag . append ( " " ) ; int count = 1 ; for ( final Map . Entry < String , String > attributte : attributes . entrySet ( ) ) { xmlTag . append ( attributte . getKey ( ) ) ; xmlTag . append ( "=" ) ; xmlTag . append ( "\"" ) . append ( attributte . getValue ( ) ) . append ( "\"" ) ; if ( count != attributes . size ( ) ) { xmlTag . append ( " " ) ; } count ++ ; } } xmlTag . append ( ">" ) ; xmlTag . append ( value ) ; xmlTag . append ( "</" ) . append ( tagname ) . append ( ">" ) ; return xmlTag . toString ( ) ; }
Creates a tag from the given string values . Can be used for creating html or xml tags .