Solved

Special characters in a Web Service xml response

Posted on 2004-09-29
2
1,840 Views
Last Modified: 2012-06-22
We have a web service that is using document/literal message encoding.  Several values returned from the web service could contain “special” characters, such as greater than (>) or less than (<).  There are two approaches that I am aware of for dealing with these special characters.  1) Wrap the data in a CDATA section  2) Escape the characters by changing them to &gt; and &lt;.

Are there any other approaches that I missed?

I am wondering if there is a recommended approach to dealing with these special characters.  Do you recommend using CDATA or escaping them?

If CDATA is the recommendation, do you recommend always adding the CDATA section or only adding the CDATA section if the data being transferred contains a “special” character?  This is really a performance question of the overhead of checking for special characters versus transferring and parsing the unneeded CDATA section.
0
Comment
Question by:SCDMETA
2 Comments
 
LVL 15

Accepted Solution

by:
dualsoul earned 500 total points
ID: 12183983
What for me, i would use simple filter to replace characters to it's entities - it can be done really fast, you know.

But if you outputs your own content,  may be it's inconvinient to filter data, may be it's faster to assemble it with CDATA sections, if you have assemle process. If you just outputs XML as is - this will be overheat.
0
 
LVL 6

Author Comment

by:SCDMETA
ID: 12229287
I am going to accept dualsoal's answer for a few reasons.  
1) You were the only one posting a response..for which I thank you.

2) You stated you use a simple filter to replace characters with it's entity escape sequence.
I was looking for some insight in how others handled their data.
We have a lot of text data, that could contain special characters, and I am still concerned about the overhead of escaping every string.
I still appreciate the feed back.

3) You agreed that using CDATA sections allows for faster XML assemble process.
I realized that using CDATA sections would be faster on the server side than escaping the data. This is true because we are assembling the XML data ourselves and it is easy to insert the CDATA character sequence before and after the data.  This would be much faster then scan each string and replacing special charaters with escaped values.

If we decide to use CDATA sections, we will probably CDATA all values instead of searching the values to determine if the actual need CDATA sections or not.
Thanks again.

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

Suggested Solutions

Title # Comments Views Activity
C# Delete from XML 10 44
Test ddwrt:UserLookup 1 65
Configure a Bean in an XML file 4 32
split XML field into many fields from MS Access 21 26
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 …
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.
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 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