Java XML Node Transform getAsText(Node n)

Here you can find the source of getAsText(Node n)

Description

get As Text

License

Open Source License

Declaration

public static String getAsText(Node n) 

Method Source Code

//package com.java2s;
// modify it under the terms of the GNU General Public License

import java.io.StringWriter;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;

import org.w3c.dom.Node;

public class Main {
    public static String getAsText(Node n) {
        try {//from w  w w .ja v  a 2  s  . c  o  m
            Transformer t = TransformerFactory.newInstance().newTransformer();
            StringWriter out = new StringWriter();
            t.transform(new javax.xml.transform.dom.DOMSource(n), new javax.xml.transform.stream.StreamResult(out));
            return out.toString();
        } catch (Throwable t) {
            t.printStackTrace();
            return null;
        }
    }
}

Related

  1. buildXml(Node node)
  2. copyTreeToResult(Node tree, Result result)
  3. createInputStream(Node node)
  4. createXML(Node doc)
  5. getHumanReadableXml(final Node node)
  6. getNodeValue(NodeList nodeList)
  7. getValueOfValueNode(Node n, boolean unescape)
  8. getXML(NodeList childNodes)