Encode string to html string

I need to convert a text string ("Dewey & Cheatham & Howe") to an XML encoded string ("Dewey & Cheatham & Howe"). I am not building an XML document, I am just trying to convert a single string. I have looked at the System.Xml namespace, but I can't quite find what I need. XmlTextWriter.WriteString() does the type of encoding I need, but it writes the string. I just want it to return the encoded string. 

Can someone tell me the class and method I need?

Pro LINQ: Language Integrated Query in C# 2008
10/17/2003 7:03:12 PM
asp.net.xml-datasource 7181 articles. 0 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 41

Check out Server.HtmlEncode.
10/17/2003 7:04:44 PM
I thought about that because I have used it in some older code I wrote, but had two issues with it.  One, I need access to it inside a class (.cs) that gets called by my aspx and it doesn't seem to be in scope.  Other than passing it in to the class, which is not very feasible, is there another way to get access to the Server object?

Also, since that is actually doing an HTML encoding, I wonder if it is not technically correct to use for XML encoding? Are the standards by definition the same? Seems like I really should use something in the System.Xml namespace to really do this properly.

Pro LINQ: Language Integrated Query in C# 2008
10/17/2003 7:16:01 PM
I really don't know about standards, but you can get to the Server object with:

10/17/2003 7:18:12 PM
Thanks.  That worked for me, and its good enough for now to get me by.  But, I am still concerned that I should be encoding it using an XML encoding and class.  If anyone knows the way to do this with an XML encoding, please post the solution.


Pro LINQ: Language Integrated Query in C# 2008
10/17/2003 7:36:25 PM

Similar Artilces:

To Encode String or to Not Encode String... Answer?
I am importing a CSV file from a Unix server as a string, and then saving the string into a new file for later processing.  However, this process does not always work.  As this CSV file is VERY, VERY large, I am unable to immediately tell if the fault lies with my code, or the CSV file provider (very possible).  The only time I can tell that this happened is when the data is not populated the next morning.  The fault appears to lie in there being extra or missing commas, as when I try to run the data import manually, STRINGs are attempted to be inserted into INT...

string() = string()
this code does not work (not instance of object) Dim Items(), Other() As String Items = New String() {"A","B","C"} Other = New String() {} Other = Items how can I get all the values ? angiras Hi, If I understand your requirement correctly, this should do it Dim Items() As String = {"A", "B", "C"} Dim Other(Items.Length - 1) As String Items.CopyTo(Other, 0) To more closely match you code above, but this will be less efficient Dim Items(), Other() As String ...

String and string?
Hi guys, I was wondering the difference between small letter string type and a capital letter String type. Does anyone know about this? Highly appreciate for your answers! Thankz! The "proper" version is String, as it references the System.String class of the .NET Framework Class Library. The ability to use string is provided by C#, where it is an alias to String. Similarly, the "proper" version of an integer is Int32, as it references System.Int32.  The ability to use int is provided by C#, and the ability to use Integer is provided by VB.NET, and both int and Integer are aliases...

string to string[]
Hi, I've got this code : string[] Params; string SQL = "SELECT * FROM T_MANAGEMENT_PAGES"; SqlCommand myCommand = new SqlCommand(SQL, myConnection); myConnection.Open(); SqlDataReader myReader = myCommand.ExecuteReader(); try { while (myReader.Read()) { Params_Type = myReader.GetValue(0).ToString(); } } catch { } finally { } myReader.Close(); My problem is to obtain Params_Type. But each time, it says : "impossible to convert '[object]' in 'string[]' &quo...

String and String[]
What will be the advantage of using myString: String[10] over myString: String Man wrote: > What will be the advantage of using > myString: String[10] > over > myString: String "String[10]" is a fixed-length, statically allocated, Ansi-based ShortString. "String" is a dynamic-length, dynamically allocated, reference counted, Ansi-based or Unicode-based (depening on Delphi version) Long string. Unless you absolutely need the static, fixed length nature of ShortString, such as in records that interact with external systems, you should stay ...

string and string[]
hello, whats the difference here between string and string[] thanks "string" denotes an item of type String "string[]" denotes an array of type String itemsThanks, EdMicrosoft MVP - ASP/ASP.NET Gracia mon ami...

String DataKeyNames for string[] datasource
 Hi, I am having a problem with a gridview.  I am binding an array of strings to the gridview and then having a problem setting the DataKeyNames.  Because the dataItem is of type string I cant place the name of any property in DataKeyNames property. gridView.DataSource = new string[] { "one", "two" };gridView.DataBind(); <asp:GridView runat="server" ID="gridView" DataKeyNames="???"> <Columns> ... </Columns> </asp:GridView> The only solution I can thing of is to convert the string array into an ar...

a string in a string in a string in my code behind....
I know my title talk about code-behind, but this is really a client-side problem (and surely a newby one too, sorry about that).I have a javascript function that my make a little text appear when the onmouseover event of a link is activated.So, normally, if my link was inside my html code, it would be something like this:<a href = "whocare.com"  onmouseover="poplink('I want to test something');">test</a>BUT, for some reason, I have to write this part in code behind with the LiteralControl function....and that will give something like that:this.Controls.Add(new LiteralCo...

m_AVP As IDictionary(Of String, String) = New Dictionary(Of String, String) ,not defined?
   I am creating a usercontrol (ascx,ascx.vb)   I have used Imports system.Collections Imports system.Collections.Generic     Private m_AttributeValuePair As IDictionary(Of String, String) = New Dictionary(Of String, String)     But I am gettting an error “Type Dictionary is not defined”   And also I am getting intelisense to type the line But what is the reason for my error ? How can I get escape from the error ?         this error is not showing today  ...

How to fetch string from url encoded string
Hello All Value of Column1 =  "<a href=\" 001,DP,CP,CP - 001\"> Hello </a>" I want to fetch "Hello" from above string. Please see if anyone can help me to fetchout this string from above string. I am using repeater control. And I have linkbutton control inside that repeater. I want to set text property of that control as following.  Text='<%#HttpUtility.HtmlDecode(Eval("Column1").ToString())%>' It shows me "Hello" but whenever I click on Link Button it adds  001,DP,CP,CP - 001 to my...

Open XML File, string.Replace a string, then Save XML file... help!
  Dim XMLFiles As String() = System.IO.Directory.GetFiles("C:\Users\App_Data\posts") For Each strFile As String In XMLFiles Try Dim xmlDoc As New System.Xml.XmlDocument xmlDoc.Load(strFile) Dim xmlNodeList As System.Xml.XmlNodeList = xmlDoc.SelectNodes( Dim es As String = xmlDoc.InnerText.Replace("<font face=""trebuchet ms,geneva"" size=""2"">", "") es = es.Replace("<font face=""...

[String].Join to concatenate HTML strings
Is there a way to use [string].Join to concatenate html stings including spaces? I want to join html strings with a special character so I can pass them as an array to javascript from the code behind.Dim Array(100) As String ArrayString = [String].Join(",", Array) This works great if each item in Array is one word only, but what if each item in Array contains spaces? You can loop through the arrays and do concatenation using stringbuilder MAKMark as Answer if this reply helps youMVP ASP/ASP.NetASP.Net Hosting : Host DepotMy Site : ASPSnippets Hey, Can you give me an e...

POST encoded xml string
HiI need to encode the xml shown below and POST it, is this a viable way or is there a better way?<message_delivery> <authentication> <user_name>MYUSERNAME</user_name> <password>MYPASSWORD</password> </authentication> <premium_route id='123' redelivered='false' test='false'> <pr_message> <text> Hello this message is sent via xml. Best of luck.</text> <originator>Mgate</originator> <recipient id='mtid_123'>441234512345</recipient> </pr_message> </premiu...

Detecting string in string
Hello I am not an advanced perl programmer and I do not have my books with me. I want to determine if a string is within a string and to not process the string if the string is found. Could someone please provide a simple sample. Thanks, Andrew On 2/22/07, andrewmchorney@cox.net <andrewmchorney@cox.net> wrote: > I am not an advanced perl programmer Have courage -- you'll get there someday! > and I do not have my books with me. That's what the perldoc command is for. > I want to determine if a string is within a string Do you want the index func...

Web resources about - Encode string to html string - asp.net.xml-datasource

Encode (semiotics) - Wikipedia, the free encyclopedia
The process of message exchanges, or semiosis , is a key characteristic of human life depending on rule-governed and learned codes that, for ...

The Story of You: ENCODE and the human genome - YouTube
Ever since a monk called Mendel started breeding pea plants we've been learning about our genomes. In 1953, Watson, Crick and Franklin described ...

Fabbing a chip that could encode data in a twisted vortex of light
Scanning electron microscope image of a silicon device that twists photons into helical shapes. The light is sent into the 8-micron-diameter ...

Casio iOS app can encode and send data using colors
Japan's Casio has released an experimental app for the iPhone and iPad that encodes and sends data using colors.

ENCODE: the rough guide to the human genome
Genetics - DNA - Back in 2001, the Human Genome Project gave us a nigh-complete readout of our DNA. Somehow, those As, Gs, Cs, and Ts contained ...

EU Aims to Encode Neutrality Rules for All Europe
... Commission (EC) VP Neelie Kroes claiming this week she'll pass new rules that would not only eliminate roaming fees in the EU, but encode net ...

Sony, Universal and Warner to use Dolby Digital Plus audio for UltraViolet common file format encodes ...
... announced that three of the major studios have chosen Dolby Digital Plus (aka E-AC-3) as their audio codec of choice for their CFF encodes. ...

ENCODE Papers Get A Fisking
Scientists can be more than a bit snarky with each other, especially in peer review. But 'On the Immortality of Television Sets...' may set a ...

To stream everywhere, Netflix encodes each movie 120 times
... screen sizes, bitrate requirements and codec support. That’s why Netflix is doing a whole lot of encoding: Each and every movie is encoded in ...

Resources last updated: 12/15/2015 2:53:48 AM