Solved

Special characters in a Web Service xml response

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 …
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

15 Experts available now in Live!

Get 1:1 Help Now