Saturday, March 31, 2012

string to xhtml

Is there a way to take a string and make it xhtml compliant? The string may contain ampersand and non breaking spaces ( ). My ajax response is bombing on a string containing a non breaking space ( ). So, is there a function that will take a string as input and return it as valid xhtml?

You can try Server.HTMLEncode( string )

http://msdn2.microsoft.com/en-us/library/ms525347.aspx

I don't see how it would blow up on the " " because there is nothing invalid about this, specifically in regards to Xhtml.

Other than that you are probably going to have to write your own function to replace characters properly.


I discovered that XML does not recognize . Instead, you have to add a document type to the top of your XML:

<!DOCTYPE stylesheet [<!ENTITY nbsp " ">

This fixes the problem.

0 comments:

Post a Comment