Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do you create a new XML file from within a Java program?

843834Jul 13 2002 — edited Jul 13 2002
I'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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 10 2002
Added on Jul 13 2002
1 comment
325 views