WebDevelopment, ColdFusion, Railo, JS, Database and Tech-related by the Co-Founder and CEO of tunesBag.com

Sunday, 28 February 2010

Fixing "An invalid XML character (Unicode: 0x0) was found in the element content of the document."

I had some issues recently with storing data in a database as WDDX package and later reading from database again ... as you know WDDX is XML based so CF/railo are using the built-in XML parser to read the data.
In this case special characters in the original content can lead to an error message like "An invalid XML character (Unicode: 0x0) was found in the element content of the document." - the solution is to escape the control chars in the string before calling CFWDDX, e.g. by calling

"REReplace(thisXML,'[\x0]','','ALL')"

I found this tip in the Adobe Forums.