<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2658.34">
<TITLE>RE: [jdom-interest] Re: jdom 1.0 XMLOutputter -- problems</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Try this....</FONT>
</P>
<P> <FONT SIZE=2>Document doc = new Document();</FONT>
<BR> <FONT SIZE=2>Element root = new Element("GREETING");</FONT>
<BR> <FONT SIZE=2>root.setText("Hello JDOM!");</FONT>
<BR> <FONT SIZE=2>doc.setRootElement(root);</FONT>
<BR> <FONT SIZE=2>XMLOutputter outputter = new XMLOutputter();</FONT>
<BR><FONT SIZE=2> File file = new File("/path/to/new/file.xml");</FONT>
<BR><FONT SIZE=2> FileOutputStream fos = new FileOutputStream(file);</FONT>
<BR> <FONT SIZE=2>outputter.output(doc, fos);</FONT>
<BR><FONT SIZE=2> fos.flush();</FONT>
<BR><FONT SIZE=2> fos.close();</FONT>
</P>
<P><FONT SIZE=2> // (plus try-catch code..)</FONT>
</P>
<BR>
<BR>
<BR>
<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: jdom-interest-bounces@jdom.org</FONT>
<BR><FONT SIZE=2>[<A HREF="mailto:jdom-interest-bounces@jdom.org">mailto:jdom-interest-bounces@jdom.org</A>]On Behalf Of Frances</FONT>
<BR><FONT SIZE=2>Sent: Thursday, May 11, 2006 10:46 AM</FONT>
<BR><FONT SIZE=2>To: jdom-interest@jdom.org</FONT>
<BR><FONT SIZE=2>Subject: [jdom-interest] Re: jdom 1.0 XMLOutputter -- problems</FONT>
</P>
<BR>
<P><FONT SIZE=2>Elliotte Harold wrote:</FONT>
<BR><FONT SIZE=2>> Frances wrote:</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>>> all examples I see to create XML files, like for example here..</FONT>
<BR><FONT SIZE=2>>></FONT>
<BR><FONT SIZE=2>>> <A HREF="http://www.cafeconleche.org/books/xmljava/chapters/ch14s03.html" TARGET="_blank">http://www.cafeconleche.org/books/xmljava/chapters/ch14s03.html</A></FONT>
<BR><FONT SIZE=2>>></FONT>
<BR><FONT SIZE=2>>> say they are creating XML files, but they're only creating what goes </FONT>
<BR><FONT SIZE=2>>> INSIDE xml file, not actual XML file.. it says on this page:</FONT>
<BR><FONT SIZE=2>>></FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> You need to read the next page. All will be revealed, though a certain </FONT>
<BR><FONT SIZE=2>> level of familiarity with Java I/O is assumed.</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> FYI, that page never says it's creating an XML *file*, only an XML </FONT>
<BR><FONT SIZE=2>> *document*. They are not the same thing, and the difference is crucial </FONT>
<BR><FONT SIZE=2>> here.</FONT>
<BR><FONT SIZE=2>> </FONT>
</P>
<P><FONT SIZE=2>thank you very much, I did go to next page (had done so previously </FONT>
<BR><FONT SIZE=2>also..) so, based on code found at above pg and next pg, I now have the </FONT>
<BR><FONT SIZE=2>following:</FONT>
</P>
<P> <FONT SIZE=2>Document doc = new Document();</FONT>
<BR> <FONT SIZE=2>Element root = new Element("GREETING");</FONT>
<BR> <FONT SIZE=2>root.setText("Hello JDOM!");</FONT>
<BR> <FONT SIZE=2>doc.setRootElement(root);</FONT>
<BR> <FONT SIZE=2>XMLOutputter outputter = new XMLOutputter();</FONT>
<BR> <FONT SIZE=2>outputter.output(doc, System.out);</FONT>
</P>
<P><FONT SIZE=2> // (plus try-catch code..)</FONT>
</P>
<P><FONT SIZE=2>this compiles and runs fine; however, it prints XML output in command </FONT>
<BR><FONT SIZE=2>line.. still haven't found how to create an actual XML file (say, </FONT>
<BR><FONT SIZE=2>info.xml) how would I do this? (yes, I AM familiar with Java I/O.. I </FONT>
<BR><FONT SIZE=2>have created files with it..) thank you very much..</FONT>
</P>
<P><FONT SIZE=2>Frances</FONT>
</P>
<BR>
<P><FONT SIZE=2>_______________________________________________</FONT>
<BR><FONT SIZE=2>To control your jdom-interest membership:</FONT>
<BR><FONT SIZE=2><A HREF="http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com" TARGET="_blank">http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com</A></FONT>
</P>
<P>This email and any files transmitted with it are confidential and proprietary to Algorithmics Incorporated and its affiliates ("Algorithmics"). If received in error, use is prohibited. Please destroy, and notify sender. Sender does not waive confidentiality or privilege. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. Algorithmics does not accept liability for any errors or omissions. Any commitment intended to bind Algorithmics must be reduced to writing and signed by an authorized signatory.</P>
</BODY>
</HTML>