Solved

XML Problem with em dash (—) when given in CDATA

Posted on 2013-11-04
4
169 Views
Last Modified: 2016-07-11
Hi Friends,

Am having the below issue when giving — in CDATA.
I mean when I give the above char set in Normal xml tag say <Subject>Test XML  &#8212;</Subject> the output is displayed correctly

output
Test XML — Email

But when i user inside CDATA am getting the same character
<SubjectBody><![CDATA[&#8212;]]></SubjectBody>

output
&#8212;

I require the same output as the first output. Please help. Thanks.
0
Comment
Question by:Suresh Sabesan
  • 2
4 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 39621393
CDATA is meant to allow special XML characters to be shown without escaping them

the "&" inside a CDATA section is equivalent to "&amp;" outside the CDATA section

So in XML terms your subject body inside the CDATA is exactly what it says, a "&" character, then a "#" character, then the character "8" etc...

Outside CDATA that "&#8212;" is an escaped unicode character 8212

Putting that escaped unicode character inside a CDATA section is plain wrong,
especting it to come out as an em-dash is against XML expectations

So if you have the power to not put the character in a CDATA section, you should

If this is how you get the data, you need to parse the text-node (because that si what the CDATA section is) using text processing tools

Saxon9PE XSLT has an extension function to parse that string, javascript has decode-html or something.
So, I need to know 2 things from you
- can you avoid the CDATA section, if so, please do
- what technology do you want to use to parse the html phrase
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 41701668
Allthough the OP abandonned the question, there is valuable information about escaping characters and CDATA sections in the reply. And other than lacking OP response, the question has been completely answered
Please accept https://#a39621393
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now