public static void modifyRootAttributes(Document doc, XmlEntity xmlEntity) {
    if (xmlEntity == null || xmlEntity.getAttributes() == null) {
      return;
    }
    String type = xmlEntity.getType();
    Map<String, String> attributes = xmlEntity.getAttributes();

    Element root = doc.getDocumentElement();
    if (root.getLocalName().equals(type)) {

      for (Entry<String, String> entry : attributes.entrySet()) {
        String attributeName = entry.getKey();
        String attributeValue = entry.getValue();

        // Remove the existing attribute
        String rootAttribute = getAttribute(root, attributeName);
        if (null != rootAttribute) {
          root.removeAttribute(rootAttribute);
        }

        // Add the new attribute with new value
        root.setAttribute(attributeName, attributeValue);
      }
    }
  }
*
Method to modify the root attribute (cache) of the XML

@param doc Target document whose root attributes must be modified
@param xmlEntity xml entity for the root , it also contains the attributes
geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/XmlUtils.java