[jdom-interest] how to append to an xml file using jdom
awais hamid
hamid_awais at hotmail.com
Wed Jun 30 14:50:24 PDT 2004
Hello friends i am deeloping a semantic cache of xml queries and xml
documents
Here is a glimpse of my code in which i am creating an xml document with
following structure
- <queries>
<query>/books/book[price>300]/bookname</query>
</queries>
SAXBuilder saxobj=new SAXBuilder();
Element rootofquery = new Element("queries");
Element elementofquery = new Element("query");
Document doc1ofquery = new Document();
elementofquery.setText(query);
rootofquery.addContent(elementofquery);
doc1ofquery.addContent(rootofquery);
In the code given below i will be saving xml o queries.xml file
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
File queryfile=new File("queries.xml");
FileOutputStream queryout=new FileOutputStream(queryfile);
outputter.output(doc1ofquery, queryout);
But every time when this script executes the previus data is overwritten
which i dont want.
What should be done? to append to existing data instead of replacing it.
I would be thankful for ur replies
_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail
More information about the jdom-interest
mailing list