Inserting CDATA into an XML element using CFMX...

Posted by Dan on May 28, 2004 @ 11:42 PM

I was having a horrible time trying to insert some CDATA into an element using the CFMX version of an XML "DOM." I use the word "DOM" very lighty w/CFMX, because it really is a hacked together solution that doesn't do much of anything well.

Anyway, I had tried everything under the sun to get my CDATA inserted and I was having absolutely no luck. If I tried to insert the text using xmlText, the CDATA tag would get escape—which is obviously not the behavior I wanted.

Fortunately, Nathan Dintenfass was quick to respond to my disperate cry on one of my mailing lists, with a link from Macromedia's LiveDocs:

http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/xml16.htm

Turns out Macromedia introduced a new XML "property" (or maybe "key" is a better word) called "xmlCDATA" which you can use to add CDATA to a node.

I hunted all over Macromedia's website and wasn't able to find this information, so big props to Nathan for pulling this link out of his hat for me!

Categories: HTML/ColdFusion

Add Comment

Leave this field empty