Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-11-04
4
Medium Priority
?
303 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
2 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

879 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