According to the XML spec, the only characters that must be escaped when used as character content rather than markup are &
(as &
, &
or &
) and <
(as <
, <
or <
), plus >
when it is part of the sequence ]]>
. In addition, single quotes must be escaped (typically as '
) in single quoted attribute values, and double quotes (typically as "
) in double-quoted attribute values, and any character that is not representable in the character encoding used to serialize the document must be escaped as a suitable character reference.
You don't have to escape double quotes in single quoted attributes or vice versa, but it won't do any harm if you do so.
Of course, you may escape every >
, "
and '
(and any other character) within character content if you want to, without changing the meaning.