• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Ouput xml content using xmlParse

New Here ,
May 05, 2012 May 05, 2012

Copy link to clipboard

Copied

Hello,

I generated a xml file in UTF-8 format which is right readeable using IE9.

This file contains some accented character and in IE9 these characters are all readeable.

After parsing this file using xmlParse and obtaining the resulting array, i try to show the content of one memo field present in an array element but the accented characters are substituted by a wrong rappresentation (like a wrong encoding).

I check (by the browser) that the page is rightly UTF-8 encoded like the xml file.

Why the accented characters are not shown in the right way despite the xml file and the page are UTF-8 encoded ?

Thanks,

Davide

Views

2.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 06, 2012 May 06, 2012

Ah, right.  Gotcha.

There's a bug in xmlParse() in that when reading from the file system, it doesn't understand that files can have different encoding schemes.  Sad but true.

See the ticket I've raised with Adobe here:

https://bugbase.adobe.com/index.cfm?event=bug&id=3183072

Short version: use fileRead() to read the file, then xmlParse() the result.

NB, according to CF, you have a bug in your XML:

<?xml version="1.0" encoding="UTF-8" standalone="true"?>

The standalone attribute value must be one of ye

...

Votes

Translate

Translate
Community Expert ,
May 06, 2012 May 06, 2012

Copy link to clipboard

Copied

When you say, "i try to show the content of one memo field present in an array element", what should we understand by show? Do you mean using cfoutput?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 06, 2012 May 06, 2012

Copy link to clipboard

Copied

Similar to BKBK's reaction... instead of describing your code, show us your code.  Or at least a code snippet that demonstrates/replicates your problem.  It's unlikely we can guess what your problem is, which is what you're relying on us doing without letting us see some code that demonstrates what you're talking about.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 06, 2012 May 06, 2012

Copy link to clipboard

Copied

Here's the code...

Following the .cfc which return me the array of xml struct:

var xmlObject = xmlParse(expandPath("Data/Pratiche.xml"));

        var xPathString = "";

        var result = "";       

       

        if (CustomerID > "")

        {

            xPathString = "/DATAPACKET/ROWDATA/ROW[@CustomerID =" & CustomerID & "]";

            result = xmlSearch(xmlObject, xPathString);           

        }

        return result;

And here there's the code which output the result :

<cfcontent type="text/xml; charset=UTF-8">

<cfinvoke component="cfcs.praticheDAO"

          method="readByParams"

          idcliente="3"

          returnvariable="pratiche">

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

    <head>

        <meta http-equiv="Content-Type"

              content="text/html; charset=UTF-8"/>

    </head>

   

    <body bgcolor="#FFFFFF" text="#000000">

        <cfoutput>

            <cfloop array="#pratiche#" index="p">   

                <div style="width:720px; font-family:Arial, Helvetica, sans-serif; font-size:11px; border:0;">

               

                    <div style="width:720px; margin:5px 0;">

                        <div style="position:relative;width:30px; border:1px solid ##333333; background-color:##ffffff; margin-left:10px; text-align:center; z-index:2">Note</div>                       

                        <div style="position:relative;width:710px; border:1px solid ##333333; border-radius:5px; padding:8px 5px 5px 5px; margin:-6px 0 5px 0; z-index:1;">

                           #p.xmlAttributes.NotePub#                        <- this is the xml value I'm trying to output

                        </div>               

                    </div>                   

               </div>           

            </cfloop>

        </cfoutput>

    </body>

</html>

The results is :

La società debitrice è in liquidazione coatta amministrativa. <- here's the wrongs charcters they should be à and è

Abbiamo provveduto a comunicare al Commissario liquidatore l'importo complessivo del credito.

Ammessi al chirografo per L.2.473.460.

DIFFIDA INVIATA E NON RICEVUTA. 1 RICEVUTA

Si è depositata la domanda di ammissione al passivo   <- here's the wrong char it should be è 

AMMESSO TUTTO AL CHIROGRAFO

Here an extract from the xml file like I view it in IE9:

<?xml version="1.0" encoding="UTF-8" standalone="true"?>

<DATAPACKET Version="2.0">

<ROWDATA>

<ROW Data="20000717" NotePub="La società debitrice è in liquidazione coatta amministrativa. Abbiamo provveduto a comunicare al Commissario liquidatore l'importo complessivo del credito. Ammessi al chirografo per L.2.473.460." AttIst="FALSE" Concordato="TRUE" Fallimento="FALSE" RagSocDeb="ORTO PIU' SOC. COOP. A R.L." CodDeb="RP49" NumDec="" Acconti="0.0000" Emissione="20001230" ValMat="0.0000" Notifica="20010103" Deposito="20001115" ValCap="1001.1899" IDCliente="3" IDPratica="196"/>

<ROW Data="20030120" NotePub="DIFFIDA INVIATA E NON RICEVUTA. 1 RICEVUTA Si è depositata la domanda di ammissione al passivo AMMESSO TUTTO AL CHIROGRAFO" AttIst="FALSE" Concordato="FALSE" Fallimento="TRUE" RagSocDeb="NIKO MARKET S.R.L." CodDeb="VQ23" Acconti="0.0000" ValMat="0.0000" ValCap="430.4600" IDCliente="3" IDPratica="1375" UdiVer="20030922"/>

</ROWDATA>

</DATAPACKET>

Finally i notify you the the application run on a ColdFusion server with an english SO and I'm viewing the page with an Italian IE9.

I hope I give you the needed information.

Thanks for your support,

Davide

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 06, 2012 May 06, 2012

Copy link to clipboard

Copied

Ah, right.  Gotcha.

There's a bug in xmlParse() in that when reading from the file system, it doesn't understand that files can have different encoding schemes.  Sad but true.

See the ticket I've raised with Adobe here:

https://bugbase.adobe.com/index.cfm?event=bug&id=3183072

Short version: use fileRead() to read the file, then xmlParse() the result.

NB, according to CF, you have a bug in your XML:

<?xml version="1.0" encoding="UTF-8" standalone="true"?>

The standalone attribute value must be one of yes or no, not true or false (this was on CF 9.0.1).

This is borne out by the guidance by the W3C: http://www.w3.org/TR/REC-xml/#sec-rmd

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 07, 2012 May 07, 2012

Copy link to clipboard

Copied

Splendid job, Adam. I have voted to have the bug fixed.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 07, 2012 May 07, 2012

Copy link to clipboard

Copied

Adam Cameron. wrote:

use fileRead() to read the file, then xmlParse() the result.

Meaning, of course, fileRead() with an encoding attribute of "UTF-8" (as you yourself point out in the bug report). Without the  encoding attribute, fileRead misbehaves just like xmlParse.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 07, 2012 May 07, 2012

Copy link to clipboard

Copied

LATEST

use fileRead() to read the file, then xmlParse() the result.

Meaning, of course, fileRead() with an encoding attribute of "UTF-8" (as you yourself point out in the bug report). Without the  encoding attribute, fileRead misbehaves just like xmlParse.

Yeah, sorry, I thought that was obvious from what I was saying, but it's perhaps a good idea to make it crystal clear.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 07, 2012 May 07, 2012

Copy link to clipboard

Copied

Hello Adam,

of course many thanks by me.

Your response arrives quickly and solve the problem.

Davide

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation