Re: [tDOM] Writing parsed xml document back to a file



On Tue, 29 Jul 2008 16:44:50 +0200, Daniel Kirsch
<Iwillnotread_daniel@xxxxxx> wrote:

I want to write a parsed XML document back to a file.

I have:

set courseFile [tDOM::xmlOpenFile $fileName];
dom parse -channel $courseFile courseDoc;

When using
$courseDoc asXML
all header information including the encoding definition are missing.

Is there something similar to tDOM::xmlOpenFile for saving a file?
And is there some documentation about tDOM::xmlOpenFile?

Hi Daniel,
not that I know of. What I do is to pass the wanted header along with
the tree to a little helper proc.
---
#
# tree2XML Write a DOM tree as XML file $fName
# (optionally preceded by $leadIn)
#
proc tree2XML {tree fName {leadIn ""}} {
set f [open $fName w]
set xml $leadIn
append xml [$tree asXML]
puts $f $xml
close $f
}
---
HTH
Helmut Giese
.



Relevant Pages