Solved

Special characters in a Web Service xml response

Posted on 2004-09-29
2
1,842 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET and XML parsing 6 89
PHP MySQL MySQLi Update Insert, and mapping XML data to MySQL Columns 13 95
write xml in vb.net 2 33
Append data to an XML file 3 16
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

830 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