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

  • SEARCH
  • Home
  • 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 8332069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:36:49+00:00 2026-06-09T02:36:49+00:00

I am using C# 3.5. I have an XML string that I pass to

  • 0

I am using C# 3.5. I have an XML string that I pass to XslCompiledTransform object. I then display the output in a WebBrowser. All is working great except that the XML elements contain extra spaces which I need to display in the WinForms HTML browser. I can’t use any javascript in the html. Here is a sample XML element:

<myelement>Here is where           extra spaces need to be retained</myelement>

I tried replacing the string ” ” with "&nbsp;"but that made the xml that the XslCompiledTransform object used to transform invalid (the XML is invalid). Then I tried replacing ” ” with "&amp;nbsp" but then the text &amp;nbsp; appeared in my html instead of a space. How can I get the extra spaces to appear?

  • 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. Editorial Team
    Editorial Team
    2026-06-09T02:36:52+00:00Added an answer on June 9, 2026 at 2:36 am

    Add

    xml:space="preserve"
    

    to your xsl stylesheet or your input doc.

    Here’s a thorough guide to whitespace handling in XSLT.

    EDIT:

    To retain white space in the rendered HTML, use css style white-space:pre on the element in which you want to preserve white-space.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xml string below that I've turned into an object using $content
Currently, I have a String object that contains XML elements: String carsInGarage = garage.getCars();
I am using XML parser.In that i have to pass one id from one
I have an xml string that I wish to traverse using LINQ to XML
I have configured in following way that spring MVC app using Spring 3.1.1.RELEASE web.xml
I have a string containing XML document using LinqtoXML What is the best way
I have a bunch of XML files I'm using for user interface and string
I have an XML based file format that I'm using to store and load
I have an xml file that I want to configure using a bash script.
I am creating XML using Linq to XML and C#. It all works great

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.