Skip to main content
Inspiring
June 29, 2010
Question

Modifying an XML file...

  • June 29, 2010
  • 1 reply
  • 414 views

I want to modify some of the data in an XML file without overwriting the entire file...

For example, let's say I have a large XML file that contains many pieces of data, but I only want to change one of them.  Do I have to read in the entire file, change that one piece of data, then write back the entire file to disk?  I would think there should be more efficient way...  Also, it would seem, when overwriting an XML file, if there's no way to simply modify one piece of data in the file, all the comments in said file would be overwritten -- unless I included them in my CF code, which is ridiculous...

So I do hope someone will be able to tell me how to modify a single entry in an XML file without having to overwrite the whole thing...  Any suggestions?

Thanks,

Laurence MacNeill

Mableton, Georgia, USA

    This topic has been closed for replies.

    1 reply

    Inspiring
    June 29, 2010

    An XML file is just a flat text file.  So you kinda do need to read the file, update it, write it back.

    --

    Adam

    Inspiring
    June 29, 2010

    Yeah, that's what I figured...  I was hoping there was some magic way that CF could do this automatically -- kind of like an .INI file in Visual C++, where you can simply change one element in the file without re-writing the whole thing...