BUG - XML Escaping in .NET

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
 
J

Jon Skeet [C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top