private Document parseXML(String xmlAsString) {
   try {
     return XMLConverter.convertToDocument(xmlAsString, false);
   } catch (Exception e) {
     throw new SaaSSystemException("Parsing failed for:\n" + xmlAsString, e);
   }
 }
  private void readColumnValue(
      Document doc,
      Map<String, String> xmlFieldXPaths,
      String columnName,
      Object value,
      ReportResultData reportData,
      int index,
      Element node)
      throws XPathExpressionException {
    if ("RESULTXML".equalsIgnoreCase(columnName)
        || "PROCESSINGRESULT".equalsIgnoreCase(columnName)) {
      Document columnValueAsDoc = parseXML((String) reportData.getColumnValue().get(index));

      if (xmlFieldXPaths.containsKey(columnName.toLowerCase())) {
        String xpathEvaluationResult =
            XMLConverter.getNodeTextContentByXPath(
                columnValueAsDoc, xmlFieldXPaths.get(columnName));
        // don't store null values but empty strings instead, to ensure
        // proper display on client side
        if (xpathEvaluationResult == null) {
          xpathEvaluationResult = "";
        }
        node.appendChild(doc.createTextNode(xpathEvaluationResult));
      } else {
        appendXMLStructureToNode(node, columnValueAsDoc);
      }
    } else {
      node.appendChild(doc.createTextNode(value.toString()));
    }
  }