I want to modify "Mit" and put "Vasavada" there via Java XML api. I know how to use Java XML API and all but my question is- 1. We have to read the file in DOM object and then modify the element for "Mit" and write the "whole" file back right? How can we avoid writing whole file back? Is there a way? This is because if this XML file too big then it would be costly operation to modify a single entry like this, right? Regards Maulin
With standard DOM, the only way is to write the whole document back to disk. There probably are some APIs that allow one to modify the document in a "random access file" way, but I'm unable to point you to one right now.
How can we avoid writing whole file back? Is there a way? This is because if this XML file too big then it would be costly operation to modify a single entry like this, right?
Depends on what your application needs to do....if its only for "rendering", you could use a style sheet and attache the style sheet to your XML file. That way you can load the xml file and style sheet nd render the data. If you want to "persist" the change, then you need to write to the disk (or a DB). regds. - m
Hi all, thank you for your answers. madhav, I want persistent storage in xml so...I guess I will end up writing whole DOM back.. Regards Maulin
Joined: Feb 11, 2002
How about I just want to filter the source XML based on some rules, and then I just need to write the new XML to another Result without changes to the source XML. In this case, what is the proper API I should use for some modifications like, for example, adding a new attribute to a node.
Thanks all, == yc
Author and all-around good cowpoke
Joined: Mar 22, 2000
You should look into SAX processing - it makes large documents much easier as long as the tranformation required is simple. You would essentially be reading/parsing the original XML document and writing the revised version at the same time. Bill