package com.ejie.p06b.utils;

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

import java.io.StringWriter;

import org.w3c.dom.Document;


public class R76bUtilities {
	
	public static String toString(Document newDoc) throws Exception{
	    DOMSource domSource = new DOMSource(newDoc);
	    Transformer transformer = TransformerFactory.newInstance().newTransformer();
	    StringWriter sw = new StringWriter();
	    StreamResult sr = new StreamResult(sw);
	    transformer.transform(domSource, sr);
	    System.out.println(sw.toString());
	    return sw.toString();  
	} 

}
