Search the web
Sign In
New User? Sign Up
tdom · tDOM - fast DOM / XPath for Tcl in C
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
CDATA in tdom   Message List  
Reply | Forward Message #1598 of 1983 |
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



Tue May 15, 2007 4:13 pm

moriz.wahl
Offline Offline
Send Email Send Email

Forward
Message #1598 of 1983 |
Expand Messages Author Sort by Date

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"> ...
Moriz Wahl
moriz.wahl
Offline Send Email
May 15, 2007
4:12 pm

... Because this is, what you normally want. The probably major technical reason is, that the XPath data model doesn't know anything about CDATA Sections. I'm...
rolf@...
Send Email
May 15, 2007
5:15 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help