Java XML Node Serialize serializeXML(Node node)

Here you can find the source of serializeXML(Node node)

Description

serialize XML

License

Open Source License

Declaration

private static String serializeXML(Node node) throws TransformerException 

Method Source Code

//package com.java2s;
/**/*from   w ww.jav  a  2s. c  o m*/
 * This file belongs to the BPELUnit utility and Eclipse plugin set. See enclosed
 * license file for more information.
 * 
 */

import java.io.ByteArrayOutputStream;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Node;

public class Main {
    private static String serializeXML(Node node) throws TransformerException {
        TransformerFactory tf = TransformerFactory.newInstance();
        Transformer t = tf.newTransformer();
        t.setOutputProperty(OutputKeys.INDENT, "yes");
        t.setOutputProperty(OutputKeys.METHOD, "xml");
        ByteArrayOutputStream bOS = new ByteArrayOutputStream();
        t.transform(new DOMSource(node), new StreamResult(bOS));
        return bOS.toString();
    }
}

Related

  1. serializeToString(Node node, String encoding)
  2. serializeToXML(Node node, boolean indent)
  3. serializeToXml(Node node, OutputStream out)
  4. serializeXML(Node e, Writer out)
  5. serializeXML(Node node)
  6. serializeXML(Node root)
  7. serializeXmlNode(Node node, Writer writer, boolean includeNode)