With the following code:
Dim x As System.Xml.Linq.XElement = _
<div>
<%= message.ToString() %>
</div>
Dim m = x.ToString()
...if message is HTML, then the < and > characters get converted to < and &rt;.
How can I force it to skip this encoding?
From stackoverflow
-
You need to open the HTML snippit as an XML document and append the document node to the Div node you are creating.
If you want to add XML (or HTML) to an existing XML document then you have to add it as XML and not as text (cause that gets encoded).
-
What is the type of your
message
variable? Ifmessage
is anXElement
, then just leave off the.ToString
call like this:Dim x As System.Xml.Linq.XElement = _ <div> <%= message %> </div> Dim m = x.ToString()
If
message
is some other type (likeStringBuilder
), then do this:Dim x As System.Xml.Linq.XElement = _ <div> <%= XElement.Parse(message.ToString()) %> </div> Dim m = x.ToString()
0 comments:
Post a Comment