From: Milo Luo Date: 2010-01-17T18:00:51+09:00 Subject: Re: How can I modify the xml file directly? Seebs wrote: > On 2010-01-17, Milo Luo wrote: >> Do you mean it's related with the file system API? > > Yes. > >> If it can located or got the node & text from XML, it should be modified >> the node or text value without too many problems. > > Not in general. > > The problem is that, unless the new value is the same length as the old > value, modifying text in the middle of the file produces problems. > > Imagine that we have a really simple XML file: > hello, world > > You want to change that to "hello, world!". So you do. And you get: > hello, world!/greet> > > See the problem? You can't make the later parts of the file move ahead; > you would actually have to rewrite the whole file. > > -s Oh, I got the meaning. It will overwrite later characters, data will lost... That's bad. -- Posted via http://www.ruby-forum.com/.