Coldfusion and invalid XML character

Share this post:

Today I had a “banging my head to the wall” time where I was confronted with this pesky error:

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

Point is that I already created the file in Coldfusion and also used xmlformat for adding the content. So it was “impossible” that there was an error in the content of the XML file. After looking around (yes, Bing or Google is sometimes really your friend) I read that the problem should be some character encoding issue. Since, I already used UTF-8 for writing and reading the file, I thought I had it covered.

Well, to spare you from reading any longer (after all you just came here for the solution ,right?) I figured that I had to escape the control chars before using xmlparse(). In other words, a simple rereplace() was the solution:

“”

Over 10 years in business.

Self-funded. No investors. No bullshit.

More than 3,000 customers worldwide.

Helpmonks - no bullshit customer engagement service

Growth starts with action

Empower your team and delight your customers.

Helpmonks - email management for small businesses