Gee Batol

Gee Batol

  • NA
  • 9
  • 14.4k

Creating a valid HTML for XML reader using C#

Apr 15 2012 6:55 PM
Hi folks,

I have constructed a simple string outputed as HTML. The resulting html is then read by a soap tool by the customer. They say the string is not a valid HTML (or xml). It's simple as string using String class in C#:

string sLink = www.mycompany.com;

var="<a href='" + sLink + "'> Click this link  </a>" ;

The resulting output is:

&lt;a href='www.mycompany.com'> Click this link &lt;/a>


Just puzzled why the lessthan char was converted to &lt; and yet the greaterthan char is left as is?

If I do this:

var="&lt;a href='" + sLink + "' &gt; Click this link &lt;/a&gt;";

Is this valid eventhough in my test tool this string shows as:

&amp;lt;a href='" + sLink + "' &amp;gt; Click this link &amp;lt;/a&amp;gt;";

Thanks



Answers (1)