Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2008

Tip: Looking for answers? Try searching our database.

XML Escaping a String?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
coconet - 25 May 2008 04:00 GMT
I have a URL like "https://aaaa.aaa/bbb/bbbb/ccc?dd=44&ee=55%c2066

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.
Jon Skeet [C# MVP] - 25 May 2008 08:19 GMT
> I have a URL like "https://aaaa.aaa/bbb/bbbb/ccc?dd=44&ee=55%c2066
>
> 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.

Signature

Jon Skeet - <skeet@pobox.com>
Web site: http://www.pobox.com/~skeet   
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com

Mike Urquiola - 27 May 2008 15:13 GMT
>> I have a URL like "https://aaaa.aaa/bbb/bbbb/ccc?dd=44&ee=55%c2066
>>
[quoted text clipped - 5 lines]
> 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&ee=55%c2066]]>
Jon Skeet [C# MVP] - 27 May 2008 19:28 GMT
> >> I have a URL like "https://aaaa.aaa/bbb/bbbb/ccc?dd=44&ee=55%c2066
> >>
[quoted text clipped - 8 lines]
> Or you can put whatever you want in a CData section.
> <![CDATA[https://aaaa.aaa/bbb/bbbb/ccc?dd=44&ee=55%c2066]]>

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.

Signature

Jon Skeet - <skeet@pobox.com>
Web site: http://www.pobox.com/~skeet   
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.