code: public static boolean rootElementMatches(FileResource fileResource, String path, String expectedRootElement) throws IOException {
          try (InputStream stream = fileResource.createStream()) {
              XMLStreamReader reader = factory.createXMLStreamReader(stream);
              while (reader.hasNext()) {
                  int event = reader.next();
                  switch (event) {
                      case XMLStreamConstants.START_ELEMENT:
                          String rootElement = reader.getLocalName();
                          return expectedRootElement.equals(rootElement);
                  }
              }
          } catch (XMLStreamException e) {
              LOGGER.warn("Cannot parse XML file '{}'.", path);
          }
          return false;
  
      }
docs: Matches a file resource for being an XML file with a specific root
  element.
  
  @param fileResource
  The file resource.
  @param path
  The path of the file resource.
  @param expectedRootElement
  The expected local name of the root element.
  @return `true` If the file is an XML file and contains the
  expected root element.
  @throws IOException
  If the file resource cannot be read.