Diogo Alves - Software Developer wrote:
Is there a way to explicitly escape special characters (particularly &
(&) and ' (')) when writing a data set with the WriteXml
method?
I know this is supposed to happen automatically (according to MS), but
in my case, it doesn't.
Well & always needs to be escaped as & unless used to start a
character or entity reference. I am pretty sure WriteXml escapes
ampersands otherwise its output is not well-formed.
As for the single quote ', escaping that is not generally necessary,
only if ' were used as an attribute value delimiter and the attribute
value contains ' itself.
If the ampersand is not escaped in your case them something is wrong.
Not sure what, maybe if you provide some details we can figure it out.
What exactly do you have, a field in a table with text containing an
ampersand like e.g. "Kibo & Xibo", and the WriteXml then does not
generate e.g.
<fieldname>Kibo & Xibo</fieldname>
but rather
<fieldname>Kibo & Xibo</fieldname>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/