code: public Map<String, String> extract(InputStream xml, String[] fields) {
      Map<String, String> parsedFields = Maps.newHashMap();
      try {
        DocumentBuilder documentBuilder = documentBuilderSupplier.get();
        if (documentBuilder == null) {
          logger.warn("Could not create DocumentBuilder");
          return parsedFields;
        }
        Document doc = documentBuilder.parse(xml);
        for (String field : fields) {
          try {
            String value = extract(doc, field);
            if (value != null) {
              parsedFields.put(field, value);
            }
          } catch (XPathExpressionException e) {
            // Ignore problems with the xpath.
            logger.warn("Invalid XPath: " + field, e);
          }
        }
      } catch (SAXException e) {
        logger.warn("Couldn't process XML into a Document", e);
      } catch (IOException e) {
        logger.warn("Problem reading input stream", e);
      }
      return parsedFields;
    }
docs: Locates the target fields in the specified XML and uses a wildcard XPath to
  identify the first matching node and return it in a map.
  
  <p>For example, for the xml: {@code <xml><bar>BAR</bar></xml></code>} and
  field "bar", this class return a map with key "bar" and value "BAR".
  
  @param xml Stream of XML to process.
  @param fields List of fields to look for.
  @return Non-null map of fieldname to value. Will only contain entries for fields found
  in the stream.