Solved

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

Posted on 2013-11-04
4
181 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

803 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