Solved

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

Posted on 2013-11-04
4
162 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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Make a UI for entering XML 3 65
Specific format 21 140
Word files to Wordpress Posts 2 22
How to use xmlReader and idatareader  ? 4 44
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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. 
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

771 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

9 Experts available now in Live!

Get 1:1 Help Now