[jdom-interest] Re: jdom 1.0 XMLOutputter -- problems
Rolf Lear
rlear at algorithmics.com
Thu May 11 08:19:48 PDT 2006
Try this....
Document doc = new Document();
Element root = new Element("GREETING");
root.setText("Hello JDOM!");
doc.setRootElement(root);
XMLOutputter outputter = new XMLOutputter();
File file = new File("/path/to/new/file.xml");
FileOutputStream fos = new FileOutputStream(file);
outputter.output(doc, fos);
fos.flush();
fos.close();
// (plus try-catch code..)
-----Original Message-----
From: jdom-interest-bounces at jdom.org
[mailto:jdom-interest-bounces at jdom.org]On Behalf Of Frances
Sent: Thursday, May 11, 2006 10:46 AM
To: jdom-interest at jdom.org
Subject: [jdom-interest] Re: jdom 1.0 XMLOutputter -- problems
Elliotte Harold wrote:
> Frances wrote:
>
>> all examples I see to create XML files, like for example here..
>>
>> http://www.cafeconleche.org/books/xmljava/chapters/ch14s03.html
>>
>> say they are creating XML files, but they're only creating what goes
>> INSIDE xml file, not actual XML file.. it says on this page:
>>
>
> You need to read the next page. All will be revealed, though a certain
> level of familiarity with Java I/O is assumed.
>
> FYI, that page never says it's creating an XML *file*, only an XML
> *document*. They are not the same thing, and the difference is crucial
> here.
>
thank you very much, I did go to next page (had done so previously
also..) so, based on code found at above pg and next pg, I now have the
following:
Document doc = new Document();
Element root = new Element("GREETING");
root.setText("Hello JDOM!");
doc.setRootElement(root);
XMLOutputter outputter = new XMLOutputter();
outputter.output(doc, System.out);
// (plus try-catch code..)
this compiles and runs fine; however, it prints XML output in command
line.. still haven't found how to create an actual XML file (say,
info.xml) how would I do this? (yes, I AM familiar with Java I/O.. I
have created files with it..) thank you very much..
Frances
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20060511/3b3e712e/attachment.htm
More information about the jdom-interest
mailing list