BUG - XML Escaping in .NET

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When adding special characters to an XML document they are escaped to distiguish them from their normal use within the body of the document

e.g. & becomes &amp
< becomes &lt; etc

My problem is that when adding text to my XML it is failing to escape apostrophe into the form &apos
When I do this manually the adding to the document results in the escaping of the ampersand giving me &amp;apos

The text I am adding is to an XMLDocument and I'm using the InnerText property of the selected node

Am I doing something wrong and if not does anyone know of a work around
 
Ken said:
When adding special characters to an XML document they are escaped to
distiguish them from their normal use within the body of the
document.

Who's doing the escaping here? Could you give a short but complete
example which demonstrates the problem?

See http://www.pobox.com/~skeet/csharp/complete.html for more details.

Note that apostrophes only need to be escaped in XML if they're in
attributes, not if they're in text nodes.
 
Back
Top