How do you create a new XML file from within a Java program?
843834Jul 13 2002 — edited Jul 13 2002I'm trying to create a blank XML document that will have the skeleton of a well formed XML document and a root node.
I'm doing this
DocumentImpl newdoc = new DocumentImpl();
Element faq = newdoc.createElement("faq");
newdoc.appendChild(faq);
to create the new document and make faq the root node but it does nothing. I've already created the file into which this root node should go using
PrintWriter out = new PrintWriter (new FileOutputStream("filename.xml"), true);
Is this correct?
Any help is greatly appreciated.