Java XML Node to String nodeToString(Node node)

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

Description

node To String

License

Open Source License

Declaration

public static String nodeToString(Node node) throws TransformerException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Node;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.StringWriter;

public class Main {
    public static String nodeToString(Node node) throws TransformerException {
        Source source = new DOMSource(node);
        StringWriter stringWriter = new StringWriter();
        Result result = new StreamResult(stringWriter);
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        Transformer transformer = transformerFactory.newTransformer();
        transformer.transform(source, result);
        return stringWriter.getBuffer().toString();
    }/*from   w  w w .  jav a2s. c  o  m*/
}

Related

  1. nodeToString(Node node)
  2. nodeToString(Node node)
  3. nodeToString(Node node)
  4. nodeToString(Node node)
  5. nodeToString(Node node)
  6. nodeToString(Node node)
  7. nodeToString(Node node)
  8. nodeToString(Node node)
  9. nodeToString(Node node)