Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 80007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:14:06+00:00 2026-05-10T21:14:06+00:00

Consider the following code in VB9: Dim text = Line1<br/>Line2 Dim markup = <span><%=

  • 0

Consider the following code in VB9:

Dim text = 'Line1<br/>Line2' Dim markup = <span><%= text %></span>.ToString 

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

Is there any way to get the value of the variable not to be HTML encoded?

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.

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:14:07+00:00Added an answer on May 10, 2026 at 9:14 pm

    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 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 81k
  • Answers 81k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Riffing off someone else's suggestion, here is a Python script… May 11, 2026 at 4:28 pm
  • Editorial Team
    Editorial Team added an answer I asked a similar question and got an answer that… May 11, 2026 at 4:28 pm
  • Editorial Team
    Editorial Team added an answer Open your application in PE Explorer, it will show you… May 11, 2026 at 4:28 pm

Related Questions

Often, programmers write code that generates other code. (The technical term is metaprogramming ,
I was of the opinion that virtualization doesnt work in the super class constructor
This has always bugged me. Perhaps someone with some hardcore knowledge of .NET internals
Consider the following code: $(a).attr(disabled, disabled); In IE and FF, this will make anchors

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.