Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-11-04
4
Medium Priority
?
272 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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. 
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

664 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