"Narahari, Sateesh" wrote:
>
> using the DOM model, you can easily make an XML document. However, saving it
> to a file will be a big pain , since AFAIK, only MSXML parser supports Save
> method.
Actually you can use something like xalan's TreeWalker in combination with
their FormatterToXML to output XML from DOM. Here's some sample code, which
is just the relevant bits that I've ripped out of one of my projects -
untested as is!
import org.apache.xalan.xpath.xml.FormatterToXML;
import org.apache.xalan.xpath.xml.TreeWalker;
FormatterToXML xmlFormatter = null;
TreeWalker treeWalker = null;
xmlFormatter = new FormatterToXML(System.out);
xmlFormatter.indent = 2;
treeWalker = new TreeWalker(xmlFormatter);
Document document;
// construct the document
treeWalker.traverse(document);
xmlFormatter.flush();
Hope this helps.
--
Warren Hedley
Department of Engineering Science
Auckland University
New Zealand
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|