private String loadXmlDefinition() {
    final Cache cache = cacheProvider.getCache();

    final StringWriter stringWriter = new StringWriter();
    final PrintWriter printWriter = new PrintWriter(stringWriter);
    CacheXmlGenerator.generate(cache, printWriter, false, false);
    printWriter.close();

    return loadXmlDefinition(stringWriter.toString());
  }
Use the CacheXmlGenerator to create XML from the entity associated with the current cache.

@return XML string representation of the entity.
geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/XmlEntity.java