code: public static void saveToXml(Node doc, File file) throws AlipayApiException {
          OutputStream out = null;
  
          try {
              Transformer tf = TransformerFactory.newInstance().newTransformer();
  
              Properties props = tf.getOutputProperties();
              props.setProperty(OutputKeys.METHOD, XMLConstants.XML_NS_PREFIX);
              props.setProperty(OutputKeys.INDENT, LOGIC_YES);
              tf.setOutputProperties(props);
  
              DOMSource dom = new DOMSource(doc);
              out = getOutputStream(file);
              Result result = new StreamResult(out);
              tf.transform(dom, result);
          } catch (TransformerException e) {
              throw new AlipayApiException("XML_TRANSFORM_ERROR", e);
          } finally {
              if (out != null) {
                  try {
                      out.close();
                  } catch (IOException e) {
                      // nothing to do
                  }
              }
          }
      }
docs: Saves the node/document/element as XML file.
  
  @param doc the XML node/document/element to save
  @param file the XML file to save
  @throws ApiException problem persisting XML file