public static String nodeToString(Node node) throws AlipayApiException {
        String payload = null;

        try {
            Transformer tf = TransformerFactory.newInstance().newTransformer();

            Properties props = tf.getOutputProperties();
            props.setProperty(OutputKeys.INDENT, LOGIC_YES);
            props.setProperty(OutputKeys.ENCODING, DEFAULT_ENCODE);
            tf.setOutputProperties(props);

            StringWriter writer = new StringWriter();
            tf.transform(new DOMSource(node), new StreamResult(writer));
            payload = writer.toString();
            payload = payload.replaceAll(REG_INVALID_CHARS, " ");
        } catch (TransformerException e) {
            throw new AlipayApiException("XML_TRANSFORM_ERROR", e);
        }

        return payload;
    }
public static String nodeToString ( Node node ) throws AlipayApiException { String payload = null ; try { Transformer tf = TransformerFactory . newInstance ( ) . newTransformer ( ) ; Properties props = tf . getOutputProperties ( ) ; props . setProperty ( OutputKeys . INDENT , LOGIC_YES ) ; props . setProperty ( OutputKeys . ENCODING , DEFAULT_ENCODE ) ; tf . setOutputProperties ( props ) ; StringWriter writer = new StringWriter ( ) ; tf . transform ( new DOMSource ( node ) , new StreamResult ( writer ) ) ; payload = writer . toString ( ) ; payload = payload . replaceAll ( REG_INVALID_CHARS , " " ) ; } catch ( TransformerException e ) { throw new AlipayApiException ( "XML_TRANSFORM_ERROR" , e ) ; } return payload ; }
Converts the Node/Document/Element instance to XML payload.

@param node the node/document/element instance to convert
@return the XML payload representing the node/document/element
@throws ApiException problem converting XML to string