Reputation: 361
I am trying to create an XML file and I have a lot of special characters like ö, ä, etc. I am using EncodeForXML
(previously used XMLFormat
) but while on the browser it looks good, if I click view source and if I save the content as an XML file, those characters are converted to ö
, ä
etc
Here is an example:
<?xml version="1.0" encoding="utf-8" ?>
<kunde>
<kdnr>118133</kdnr>
<fullname>Conny Rönnbäck</fullname>
<delname1>Conny Rönnbäck</delname1>
<delname2></delname2>
<delstreet>Löftets gränd 1</delstreet>
<delcountry>SE</delcountry>
<delzipcode>90363</delzipcode>
<deltown>Umeå</deltown>
<phone></phone>
<mobile></mobile>
</kunde>
Any ideas how to make the EncodeForXML
function to display correct special characters?
Upvotes: 0
Views: 311
Reputation: 14859
What exactly are you trying to do with the XML? That's exactly what that function does. It encodes certain characters so they can be interpreted correctly by an XML parser.
<cfsavecontent variable="foo">
<kunde>
<kdnr>118133</kdnr>
<fullname>Conny Rönnbäck</fullname>
<delname1>Conny Rönnbäck</delname1>
<delname2></delname2>
<delstreet>Löftets gränd 1</delstreet>
<delcountry>SE</delcountry>
<delzipcode>90363</delzipcode>
<deltown>Umeå</deltown>
<phone></phone>
<mobile></mobile>
</kunde>
</cfsavecontent>
<cfdump var="#xmlParse(foo)#">
Update: If you need to send the actual characters. then remove the encodeForXML()
function and wrap each node's content with [CDATA][1]
.
The term CDATA, meaning character data, is used for distinct, but related, purposes in the markup languages SGML and XML. The term indicates that a certain portion of the document is general character data, rather than non-character data or character data with a more specific, limited structure.
<fullnane><![CDATA[#someQuery.fullname#]]></fullname>
Upvotes: 1