boolean setAttribute ( String name , String value ) { if ( value == null ) { return attributes . add ( new Attribute ( name ) ) ; } for ( Attribute attribute : attributes ) { if ( attribute . getName ( ) . equals ( name ) ) { attribute . setValue ( value ) ; // update with new value return true ; } } return attributes . add ( new Attribute ( name , value ) ) ; }
Sets an attribute on an element