<p>Consider the following code in VB9:</p>

<pre><code>Dim text = "Line1&lt;br/&gt;Line2"
Dim markup = &lt;span&gt;&lt;%= text %&gt;&lt;/span&gt;.ToString
</code></pre>

<p>While I was hoping markup would end up being <code>&lt;span&gt;Line1&lt;br/&gt;Line2&lt;/span&gt;</code>, it actually evaluates to <code>&lt;span&gt;Line1&amp;lt;br/&amp;gt;Line2&lt;/span&gt;</code>.</p>

<p>Is there any way to get the value of the variable not to be HTML encoded?</p>

<p>P.S.: This is an oversimplified example of what I'm trying to do. I know this could be rewritten a number of ways to make it work, but the way my code is constructed, un-encoding the variable would be optimal. If that's not possible, then I'll go down a different road.</p>

<p>More detail: The "text" is coming from a database, where a user can enter free-form text, with carriage returns. The output is HTML, so somehow I need to get the value from the database and convert the carriage returns to line breaks.</p>

This behavior is "By Design."  When embedding a string expression inside an XML literal the value will be escaped to be a legal string value.
To get the behavior you are looking for you'll need to be embedding an XElement/XNode within an XML literal.  Take the following example.  It will correctly keep the
```
<br/>
```
tag as an XElement.
```
```
Dim text2 = <a>Line<br/>Line</a>
Dim markup2 = <span><%= text2 %></span>.ToString
```
```
One way to achieve this is to fake an XElement.  To make the text a valid string, simply wrap it on both ends with a normal tag,
```
<a>
```
for example.  This is now a parsable XML fragment.  Once you have an XElement, it's easy to get the embedded behavior you are looking for
```
```
Dim text = "Line1<br/>Line2"
Dim text2 = XElement.Parse("<a>" + text + "</a>")
Dim markup = <span><%= text2.Nodes %></span>.ToString
```
```