Re: Save changes in the original XML file
- From: "haigang0708@xxxxxxxxx" <haigang0708@xxxxxxxxx>
- Date: Tue, 18 Nov 2008 18:00:16 -0800 (PST)
On 11月18日, 下午11时03分, suchenwi <richard.suchenwirth-
bauersa...@xxxxxxxxxxx> wrote:
On 18 Nov., 15:11, "haigang0...@xxxxxxxxx" <haigang0...@xxxxxxxxx>
wrote:
I'm trying to update XML file using DOM. But as the dom-tree is stored
in memory, i found the original XML file is not updated after i
modified the value of certain nodes.
Is there any command that saves changes of nodes into the original XML
file?
In tdom that would be (assoming root is the top documentElement):
set f [open $outfile w]
#-- maybe fconfigure -encoding, write <?xml ...> line
$f puts [$root asXML]
close $f
Check your documentation, I'm quite sure tcldom has similar
functionality.
Thanks a lot.
This does works. But in the updated file, XML declaration is missing.
I also tried like this:
set doc [dom parse [read $f]]
close $f
#configure
set f [open $outfile w]
$doc asXML -channel $f
flush $f
close $f
But XML declaration was also missing.
How to fix this?
Thanks!
.
- Follow-Ups:
- Re: Save changes in the original XML file
- From: suchenwi
- Re: Save changes in the original XML file
- References:
- Save changes in the original XML file
- From: haigang0708@xxxxxxxxx
- Re: Save changes in the original XML file
- From: suchenwi
- Save changes in the original XML file
- Prev by Date: Re: NEWBIE commentary on example code
- Next by Date: Re: Save changes in the original XML file
- Previous by thread: Re: Save changes in the original XML file
- Next by thread: Re: Save changes in the original XML file
- Index(es):