"Tony" <To**@discussions.microsoft.com> wrote in message news:87**********************************@microsof t.com...
Are these the only three reserved characters ?
There are five reserved characters (although when they must
be reserved varies, as I'll explain momentarily):
< < >
& &
" "
' '
You must replace '<' with "<" when it appears in text child nodes
of an element. If you fail to do so, the XML parser will expect the
start of a nested child element (which isn't what you want). OTOH,
'>' you can usually leave alone.
You must replace '&' with "&" all of the time. If you fail to do
so, the XML parser will interpret it as you attempting to escape
another character (these are called "character entities").
You must either replace ''' with "'" OR '"' with """ (but
you do not need to do both) within attribute values. The character
that must be escaped is the character you're using to delimit your
attribute value. That is, if your attribute value is delimited by single
quotes, then you must escape ' when they appear in the value of
that attribute (e.g., O'Reilly ... name='O'Reilly' must be escaped as
name='O'Reilly'), otherwise if your attribute value is delimited
by double quotes then you must escape " when they appear in the
value of the attribute (i.e., if you had said ... name="O'Reilly" then
you wouldn't have to escape anything because the XML parser is
not going to be confused.)
To recap, always replace &. Replace <. Replace the quote character
used to delimit attribute values inside of attribute values.
Inside of a CDATA section, you must escape "]]>" as "]]<", but this
is the only thing you need to escape inside of a CDATA section.
Derek Harmon