Hello,
although there is so much spam on the tdom-group, I hope to find some help
this way.
I have an XML-Document looking like this:
<Equation ID="Equ1">
<EquationSource Format="TEX">
<![CDATA[$$
P_{i} = \hat k{\left( {D_{1} ,D_{2} , \ldots D_{n} } \right)}\,,
$$]]></EquationSource></Equation>
--------------------------------------------------------------------------
I tried this simple script:
#! /usr/bin/tclsh8.4
package require tdom
encoding system utf-8
set file [lindex $argv 0]
set infile [open $file r]
set xml [read $infile]
close $infile
## parsing input to dom
set doc [dom parse $xml]
## setting the root-node
set root [$doc documentElement]
puts [$doc asXML -indent none]
--------------------------------------------------------------------------------\
----------------
What happened is, that the CDATA sections disappeared and became TEXT_NODEs
instead. Why?
I wrote a workaround like this:
-------------------------------------------------------
foreach node [$root selectNodes //EquationSource] {
set mynode [$node selectNodes text()]
$doc createCDATASection [$mynode data] cdata
$node appendChild $cdata
$mynode delete
}
------------------------------------------------------
and got the output I wanted. Why this workaround. There could be other
CDATA_SECTION_NODEs which I do not know before.
Thanks for your interest
Moriz Wahl