Followup to XML Post

Yesterday I wrote a post about an issue I found with isXML. Lots of good suggestions/ideas were posted in the comments, including one by Rick O which seems to have nailed down the issue. Basically, if you have an invalid tag within a CDATA block, ColdFusion will report the XML as being invalid. The specs say (from what I found), that anything should be allowed in CDATA. It seems like this would be a bug in ColdFusion. Here is a simple sample:

<cfsavecontent variable="test"> <foo> <![CDATA[ <b>fdoo</i ]]> </foo> </cfsavecontent>

<cfoutput>#isxml(test)#</cfoutput> </code>

The bad I tag at the end is enough to break ColdFusion’s isXML function.

Something to look out - and of course - don’t forget the issues with xmlFormat as well. xmlFormat will ignore “high” characters (like funky Microsoft quotes) resulting in XML that won’t be valid. My toXML CFC has it’s own xmlFormat function that tries to get around this.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments