code: private static void updateAttribute(Element parent, String attrName, String value) {
  
          if (parent != null) {
              Attribute attribute = parent.attribute(attrName);
              if (value != null) {
                  if (attribute == null) {
                      parent.addAttribute(attrName, value);
                  } else {
                      attribute.setValue(value);
                  }
              } else {
                  // remove only if exists
                  if (attribute != null) {
                      parent.remove(attribute);
                  }
              }
          }
      }
docs: Updates the given xml element attribute with the given value.<p>
  
  @param parent the element to set the attribute for
  @param attrName the attribute name
  @param value the value to set, or <code>null</code> to remove