On 11/6/06, Josh Nathanson <[EMAIL PROTECTED]> wrote:
> Hey all,
>
> I've got a script that uses <cfxml> to create an xml object from data taken
> from a db.  Occasionally control characters sneak into the database and
> break the xml when I try to do the output.  I've been able to use rereplace
> to "clean" the xml until today.  I got the old  "An invalid XML character
> was found in the element content of the document." cf error with the Unicode
> value that is breaking the xml.  In the past, I've been able to add the
> corresponding #chr()# into my rereplace statement to remove the offending
> character, but this time it's Unicode 0x0 - when I add #chr(0)# into my
> rereplace, it's still not removing that character.
>
> The rereplace is big and ugly, it looks like this
> <cfset xmltest = rereplace(xmltest,
> "[#chr(5)##chr(6)##chr(8)##chr(11)##chr(15)##chr(18)##chr(20)##chr(21)##chr(38)#]",
> "", "All")>
>
> Those chr's represent all the previous characters that have cropped up in
> the past to break the xml.
>
> Any ideas how I can clean this unicode 0x0 character from the xml?

Don't know whether it'll work for you, but the regex I've used
successfully is REReplace ( mystring, '>\s*<', '><', 'ALL' ).  It
clears any whitespace between tags themselves.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:259328
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to