I would first convert the XML Document into a String, then write the
String to a file. The first part would be like...
// may not need all these but at least a few
import java.io.*;
import java.util.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.dom.DOMSource;
import org.xml.sax.InputSource;
public static final String getDocumentAsString(Document document)
throws XMLHelperException
{
try
{
// Create source and result objects
Source source = new DOMSource(document);
StringWriter out = new StringWriter();
Result result = new StreamResult(out);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.transform(source, result);
return out.toString();
}
catch(Exception e)
{
throw new XMLHelperException("XML Document to String Error", e);
}
}
From there google on writing a String to a new file.
HTH,
iksrazal
http://www.braziloutsource.com/