Solved

Special characters in a Web Service xml response

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
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 video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

13 Experts available now in Live!

Get 1:1 Help Now