Re: [tDOM] Writing parsed xml document back to a file
- From: Neil Madden <nem@xxxxxxxxxxxxx>
- Date: Wed, 30 Jul 2008 12:11:33 +0100
Daniel Kirsch 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.
That's because tDOM can't know what encoding you've configured the output channel to. As you control this (using [chan configure -encoding]), it is up to you to output the appropriate XML header. It's easy enough to do:
proc xmlWriteFile {doc file} {
set out [open $file w]
chan configure $out -encoding utf-8
puts $out "<?xml version='1.0' encoding='utf-8'?>"
puts $out [$doc asXML]
close $out
}
-- Neil
.
- References:
- [tDOM] Writing parsed xml document back to a file
- From: Daniel Kirsch
- [tDOM] Writing parsed xml document back to a file
- Prev by Date: Re: New Canvas
- Next by Date: Re: User Input Question
- Previous by thread: Re: [tDOM] Writing parsed xml document back to a file
- Next by thread: How to increase buffer for text widget
- Index(es):
Relevant Pages
|