473,396 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Encode XML

Hi All,

When sending an XML \ SOAP request, if the value looks as follows:

<TEST> My Test & Son </TEST>

How should the & be encoded. What is this "TYPE" of encoding called, and
where can I find a spec on which values should and should not be encoded
.... I know the W3C will have something but I can't for the life of me
decode it from their docs.

Thanks
Warrick
Jul 20 '05 #1
4 4779
"Warrick FitzGerald" <nn**************@crtman.com> wrote in message
news:pa****************************@crtman.com...
When sending an XML \ SOAP request, if the value looks as follows:

<TEST> My Test & Son </TEST>

How should the & be encoded.
&amp;
What is this "TYPE" of encoding called
Predefined entities. You could also use numeric character references like
& but that requires looking up (uni) codes.
and
where can I find a spec on which values should and should not be encoded
XML 1.0 spec.
... I know the W3C will have something but I can't for the life of me
decode it from their docs.


To boil it down, two characters need to be escaped if they appear in
attribute values or text outside of CDATA sections:

& as &amp; or equivalent
< as &lt; or equivalent

Two other characters are sometimes handy to escape:

" as &quot; or equivalent
' as &apos; or equivalent

The other predefined entity is &gt; but AFAIK you never _need_ to use it.

Bob Foster
Jul 20 '05 #2
>>>>> "Warrick" == Warrick FitzGerald <nn**************@crtman.com> writes:

Warrick> Hi All, When sending an XML \ SOAP request, if the value looks as
Warrick> follows:

Warrick> <TEST> My Test & Son </TEST>

Warrick> How should the & be encoded. What is this "TYPE" of encoding
Warrick> called, and where can I find a spec on which values should and
Warrick> should not be encoded ... I know the W3C will have something but I
Warrick> can't for the life of me decode it from their docs.

I am not sure if it is enought, but ZSI (a Python SOAP package) uses
following encodings for text:

& &amp;
< &lt;
"> &gt;
\015 &#xD;

and following for attributes

& &amp;
< &lt;
" &quot;
\011 &#x9;
\012 &#xA;
\015 &#xD;

(from file compat.py)
--
Arto V. Viitanen av@cs.uta.fi
University of Tampere, Department of Computer and Information Sciences
Tampere, Finland http://www.cs.uta.fi/~av/
Jul 20 '05 #3
"Bob Foster" <bo********@comcast.net> wrote in
news:8m*******************@rwcrnsc51.ops.asp.att.n et:
The other predefined entity is &gt; but AFAIK you never _need_
to use it.


Not quite "never". If you have the string ]]> in content, but not as
the end of a CDATA section, you need to escape the >.

--
a. m. slotnik
Jul 20 '05 #4
In article <Xn***************************@204.127.36.1>,
arnold m. slotnik <sl*****@att.net> wrote:
Not quite "never". If you have the string ]]> in content, but not as
the end of a CDATA section, you need to escape the >.


Or one of the ]s.

-- Richard
--
Spam filter: to mail me from a .com/.net site, put my surname in the headers.

FreeBSD rules!
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: francescomoi | last post by:
Hi. I'm trying to store a text within a MySQL field (v 3.23.58) by using MySQLdb (v 1.2.1c3). The text is: "telephone..." (note the last character) And I get this error message:...
5
by: Scott Matthews | last post by:
I've recently come upon an odd Javascript (and/or browser) behavior, and after hunting around the Web I still can't seem to find an answer. Specifically, I have noticed that the Javascript...
4
by: Newbie | last post by:
How would I modify this form to encode *all* the characters in the 'source' textarea to the '%xx' format & place result code into the 'output' textarea? (cross browser compatable) Any help is...
3
by: Peter | last post by:
Hi, I try to make up a javascript string which contains numeric numbers in any positions. For example, I want to make a string: secretcode, where secretcode.charAt(0)==(-21),...
1
by: AR | last post by:
I would like to know more about the Encode/Decode feature available within MS Access. This is what I have read from Microsoft Office OnLine: "The simplest method of protection is to encode the...
4
by: Darrel | last post by:
How does HTML.encode work? I'm trying to save text in a hidden form field into a SQL DB. The tedt is HTML (from a WYSIWYG editor...X-standard). One problem I have is that stray apostrophe's in...
7
by: jtfaulk | last post by:
I need to encode some information on the server side using ASP.NET with C#; sending via HTTP to a client side application, that needs to be decoded in an MFC C++ application. I'm not sure if I...
6
by: 7stud | last post by:
s1 = "hello" s2 = s1.encode("utf-8") s1 = "an accented 'e': \xc3\xa9" s2 = s1.encode("utf-8") The last line produces the error: --- Traceback (most recent call last):
4
by: J Peyret | last post by:
Well, as usual I am confused by unicode encoding errors. I have a string with problematic characters in it which I'd like to put into a postgresql table. That results in a postgresql error so I...
1
by: anonymous | last post by:
1 Objective to write little programs to help me learn German. See code after numbered comments. //Thanks in advance for any direction or suggestions. tk 2 Want keyboard answer input, for...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.