Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.StringWriter;

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

import org.w3c.dom.Document;

public class Main {
    public static void main(String[] argv) throws Exception {
    }

    static String getXMLString(Document xmlDoc) throws Exception {
        StringWriter writer = null;
        DOMSource source = new DOMSource(xmlDoc.getDocumentElement());
        writer = new StringWriter();
        StreamResult result = new StreamResult(writer);
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = tFactory.newTransformer();
        transformer.transform(source, result);
        StringBuffer strBuf = writer.getBuffer();
        return strBuf.toString();
    }
}