hi ,
i am having an XML file and i would like to append a node at to the
document ................. i know you can use DOM to build the whole
tree and then append to the root and then write to the file.........my
question is this...............can we do this without re-writing the
file each and every time..............??? like some appending to the
xml file????
Arne Vajhøj - 20 Aug 2006 00:33 GMT
> i am having an XML file and i would like to append a node at to the
> document ................. i know you can use DOM to build the whole
> tree and then append to the root and then write to the file.........my
> question is this...............can we do this without re-writing the
> file each and every time..............??? like some appending to the
> xml file????
Since appending to an XML file will make it invalid, then NO.
Arne
crazzybugger - 20 Aug 2006 04:26 GMT
> > i am having an XML file and i would like to append a node at to the
> > document ................. i know you can use DOM to build the whole
[quoted text clipped - 6 lines]
>
> Arne
so if i am having a very big XML file it tends to be a waste of time
trying to add new elements.........
Arne Vajhøj - 20 Aug 2006 16:37 GMT
> so if i am having a very big XML file it tends to be a waste of time
> trying to add new elements.........
If you have huge data that you need to update frequently, then
XML is not a good choice for storage.
Arne
Arne Vajhøj - 20 Aug 2006 16:38 GMT
>> so if i am having a very big XML file it tends to be a waste of time
>> trying to add new elements.........
>
> If you have huge data that you need to update frequently, then
> XML is not a good choice for storage.
Correction:
If you have huge data that you need to update frequently, then
a single XML file is not a good choice for storage.
Arne
relogout@gmail.com - 20 Aug 2006 01:35 GMT
you should know the struture of the XML file first
so.........you must parse it any way before appanding something
> hi ,
>
[quoted text clipped - 4 lines]
> file each and every time..............??? like some appending to the
> xml file????
Rohit Kumbhar - 20 Aug 2006 12:34 GMT
> hi ,
>
[quoted text clipped - 4 lines]
> file each and every time..............??? like some appending to the
> xml file????
Castor can take away a lot of pains.
http://www.castor.org/
William Brogden - 20 Aug 2006 16:56 GMT
> hi ,
>
[quoted text clipped - 4 lines]
> file each and every time..............??? like some appending to the
> xml file????
The way to handle this is to not have the file be a complete
XML document - in other words, leave out the xml declaration
and the root element. Then you can append nodes all you want.
Of course, in order to parse the file you need to contrive to
add the missing root - this is easily done since parsers just
want a character stream - you can use java.io.SequenceInputStream
to combine a String representing the document root, the file of
node data and a String representing the closing root element.
For an even more complex example:
http://www.xml.com/pub/a/2003/07/16/fragmentreader.html
Bill
crazzybugger - 20 Aug 2006 19:08 GMT
> > hi ,
> >
[quoted text clipped - 18 lines]
>
> Bill
excellent idea! i really liked it.......... i shall try implementing it