Re: How to escape text in CSharp console program
Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance
- From: "Gilles Kohl [MVP]" <no_email_available@>
- Date: Thu, 22 May 2008 10:31:35 +0200
On Thu, 22 May 2008 15:44:03 +0800, "Alan Mosley" <me@work> wrote:
I have a console app, that creates a xml file, I need to escape the data
before dumping it in the xml file.
I would use Server.HTMLEncode if it was ASP.NET.
As an answer to the question "How can I HTMLEncode a string in a
non-ASP application", try adding a reference to System.Web, and use
(e.g.)
string encodedString =
System.Web.HttpUtility.HtmlEncode("a&b");
I tried System.Xml.XmlConvert.EncodeName("a&b")
this gives me a_x0026_b I was exspecting a&b
Maybe thios is ok. the xml file is a google sitemap, it need to be read by
google bot, will it read a_x0026_b as a&b I dont know.
any help, ideas?
A question that comes to mind is why you need to escape the data
yourself though - how is your console application creating the XML
file?
Regards,
Gilles.
.
Relevant Pages
- Pattern matching question for Swindle
... I'm using PLT scheme with Swindle and SSAX to write a simple program which locates and plays songs using the iTunes Music Library XML file. ... (string "Rhapsody in Blue") ... (comp.lang.scheme) - Re: Read XML file using OOP
... // Open the XML file that has the XML text. ... string make = gcnew String carNode->Attributes ... private int _milage; ... (microsoft.public.dotnet.languages.csharp) - Re: SAX - is there an equivalent to the DOM .nodeTypedValue for reading the whole node data at o
... SAX. ... decode this data and generate the appropriate images onto disk. ... Private Sub IVBSAXContentHandler_characters(text As String) ... The XML file will contain 100s of images, ... (comp.text.xml) - Re: XML JDOM
... I have some problem in one of my xml file which value "&" in it. ... String content_id = attribute.getValue; ... // get all root child elements ... for (Iterator iter = allChildren.iterator(); ... (comp.lang.java.programmer) - RE: writing to a specific point in an array file
... Hi Melanieab, ... would be in an XML file rather than a text file and trying to manipulate ... basically writing an empty string over the current row. ... > array file, but I wasn't sure how to replace just one item. ... (microsoft.public.dotnet.languages.csharp) |
|