xml parsing.............  
Author Message
crazzybugger





PostPosted: 2006-8-20 0:07:00 Top

java-programmer, xml parsing............. 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鴍





PostPosted: 2006-8-20 7:33:00 Top

java-programmer >> xml parsing............. crazzybugger wrote:
> 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
 
relogout@gmail.com





PostPosted: 2006-8-20 8:36:00 Top

java-programmer >> xml parsing............. you should know the struture of the XML file first
so.........you must parse it any way before appanding something
crazzybugger wrote:
> 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????

 
 
crazzybugger





PostPosted: 2006-8-20 11:26:00 Top

java-programmer >> xml parsing............. Arne Vajh鴍 wrote:
> crazzybugger wrote:
> > 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

so if i am having a very big XML file it tends to be a waste of time
trying to add new elements.........

 
 
Rohit Kumbhar





PostPosted: 2006-8-20 19:34:00 Top

java-programmer >> xml parsing............. crazzybugger wrote:
> 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????
>

Castor can take away a lot of pains.
http://www.castor.org/
 
 
Arne Vajh鴍





PostPosted: 2006-8-20 23:38:00 Top

java-programmer >> xml parsing............. crazzybugger wrote:
> 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鴍





PostPosted: 2006-8-20 23:38:00 Top

java-programmer >> xml parsing............. Arne Vajh鴍 wrote:
> crazzybugger wrote:
>> 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
 
 
William Brogden





PostPosted: 2006-8-20 23:56:00 Top

java-programmer >> xml parsing............. On Sat, 19 Aug 2006 11:07:13 -0500, crazzybugger <email***@***.com>
wrote:

> 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????
>

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





PostPosted: 2006-8-21 2:08:00 Top

java-programmer >> xml parsing.............
William Brogden wrote:
> On Sat, 19 Aug 2006 11:07:13 -0500, crazzybugger <email***@***.com>
> wrote:
>
> > 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????
> >
>
> 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

excellent idea! i really liked it.......... i shall try implementing it