xml parsing.............

C

crazzybugger

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

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

crazzybugger said:
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
 
R

relogout

you should know the struture of the XML file first
so.........you must parse it any way before appanding something
 
C

crazzybugger

Arne said:
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.........
 
R

Rohit Kumbhar

crazzybugger said:
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/
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

crazzybugger said:
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
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Arne said:
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
 
W

William Brogden

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
 
C

crazzybugger

William said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,416
Messages
2,571,562
Members
48,797
Latest member
shadowoftheunknown

Latest Threads

Top