Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
microsoft.public.dotnet.framework
XML Escaping a String?
coconet
5/25/2008 3:01:00 AM
I have a URL like "
https://aaaa.aaa/bbb/bbbb/ccc?dd=44&e...
And I wan to put it in an XML configuration file. Trying to use
HttpUtility to HTML encode it is not enough, I need to "XML Encode"
it, how can I do that?
Thanks.
3 Answers
Jon Skeet
5/25/2008 7:19:00 AM
0
coconet <coconet@community.nospam> wrote:
>
> I have a URL like "
https://aaaa.aaa/bbb/bbbb/ccc?dd=44&e...
>
> And I wan to put it in an XML configuration file. Trying to use
> HttpUtility to HTML encode it is not enough, I need to "XML Encode"
> it, how can I do that?
If you want to put it in an XML file, I'd use the XML APIs to create
the XML file in the first place - they will usually take care of all
this for you.
--
Jon Skeet - <skeet@pobox.com>
Web site:
http://www.pobox....
Blog:
http://www.msmvps.com...
C# in Depth:
http://csharpi...
Mike Urquiola
5/27/2008 2:14:00 PM
0
"Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:MPG.22a3234bc3e39c75cdc@msnews.microsoft.com...
> coconet <coconet@community.nospam> wrote:
>>
>> I have a URL like "
https://aaaa.aaa/bbb/bbbb/ccc?dd=44&e...
>>
>> And I wan to put it in an XML configuration file. Trying to use
>> HttpUtility to HTML encode it is not enough, I need to "XML Encode"
>> it, how can I do that?
>
> If you want to put it in an XML file, I'd use the XML APIs to create
> the XML file in the first place - they will usually take care of all
> this for you.
>
Or you can put whatever you want in a CData section.
<![CDATA[
https://aaaa.aaa/bbb/bbbb/ccc?dd=44&e...
]]>
Jon Skeet
5/27/2008 6:28:00 PM
0
Mike Urquiola <mike@urquiola.org> wrote:
> >> I have a URL like "
https://aaaa.aaa/bbb/bbbb/ccc?dd=44&e...
> >>
> >> And I wan to put it in an XML configuration file. Trying to use
> >> HttpUtility to HTML encode it is not enough, I need to "XML Encode"
> >> it, how can I do that?
> >
> > If you want to put it in an XML file, I'd use the XML APIs to create
> > the XML file in the first place - they will usually take care of all
> > this for you.
> >
>
> Or you can put whatever you want in a CData section.
> <![CDATA[
https://aaaa.aaa/bbb/bbbb/ccc?dd=44&e...
]]>
Well, so long as your data doesn't contain ]]>
It makes it harder to read the strings which don't need it, however.
I'm also not sure whether or not it works for attributes. I think it's
generally simpler to use a proper XML API whose job is to hide things
like this.
--
Jon Skeet - <skeet@pobox.com>
Web site:
http://www.pobox....
Blog:
http://www.msmvps.com...
C# in Depth:
http://csharpi...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
XML Escaping a String?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password