Sam Gentile [mailto:[EMAIL PROTECTED]] wrote:

> This is a pretty simple question but I want to be able to
> write out "&" as part of an Xml string. The doc says:
> WriteString does the following
>
> The characters &, <, and > are replaced with &amp;, &lt;, and
> &gt;, respectively. So I get &amp;amp.
>
> How can I escape the characters?

Sam,

If I understand what you're asking, I don't think there's actually problem
here. This is technically going to result in what you're looking for when
someone parses the XML. If you pass "&amp;" as say the value of a text node,
it should end up in the XML document exactly as you're saying it does
"&amp;amp;". Then, when someone parses this document, the parser should
translate the "&amp;" entity as an "&" only, resulting in the *value* of the
text node being "&amp;" again. If it didn't encode your "&" on the way in,
when someone read the value out they would get "&" only.

It's confusing, but I think it's right.

Later,
Drew

[ .NET MVP | weblog: http://radio.weblogs.com/0104813/ ]

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to