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 901095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:30:07+00:00 2026-05-15T15:30:07+00:00

I have a problem with my XML that I am trying to display on

  • 0

I have a problem with my XML that I am trying to display on my ASP.NET page that I could do with some help with.
What I would like to do is display it on a multi-line so I have an XML file that looks like this:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="News.xslt" ?>
<newslist>
  <news>
    <date>20th June 2010</date>
    <detail>Detail line 1.
            Detail Line 2</detail>
  </news>
  <news>
    <date>18th June 2010</date>
    <detail>Some more details</detail>
  </news>
</newslist>

And I have an XSLT file that looks like this:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

  <xsl:template match="/">
    <HTML>
      <BODY>
        <xsl:for-each select="newslist/news">
          <xsl:sort select="date" order="descending"/>
          <br />
          <h3><xsl:value-of select="date" /></h3>
          <ul>
            <p><xsl:value-of select="detail" /></p>
          </ul>
        </xsl:for-each>
      </BODY>
    </HTML>
  </xsl:template>
</xsl:stylesheet>

When it displays the first detail line everything is on the same line. I’ve done some digging about and I have tried the following:

  1. xml:space=”preserve” in the XSLT file
  2. in the XML file
  3. <br />
  4. I’ve even tried leaving it as it is.

I am using Microsoft Visual Web Developer 2010. The control I am using is the XML control under the standard tab, and the language I am using is C#, if that helps any.

If this has already been answered and I haven’t found it yet can you please point me at it.

Thanks for your help.

  • 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-05-15T15:30:07+00:00Added an answer on May 15, 2026 at 3:30 pm

    This transformation:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
    
      <xsl:template match="/">
        <HTML>
          <BODY>
            <xsl:for-each select="newslist/news">
              <xsl:sort select="date" order="descending"/>
              <br />
              <h3><xsl:value-of select="date" /></h3>
              <ul>
                <p><xsl:apply-templates select="detail"/></p>
              </ul>
            </xsl:for-each>
          </BODY>
        </HTML>
      </xsl:template>
    
      <xsl:template match="detail/text()" name="textLines">
       <xsl:param name="pText" select="."/>
    
        <xsl:choose>
            <xsl:when test="contains($pText, '&#xA;')">
              <xsl:value-of select="substring-before($pText, '&#xA;')"/>
              <br />
              <xsl:call-template name="textLines">
                <xsl:with-param name="pText" select=
                 "substring-after($pText, '&#xA;')"
                 />
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise><xsl:value-of select="$pText"/></xsl:otherwise>
        </xsl:choose>
      </xsl:template>
    </xsl:stylesheet>
    

    when applied on the provided XML document:

    <newslist>
      <news>
        <date>20th June 2010</date>
        <detail>Detail line 1.
                Detail Line 2</detail>
      </news>
      <news>
        <date>18th June 2010</date>
        <detail>Some more details</detail>
      </news>
    </newslist>
    

    produces the wanted, correct result:

    <HTML>
        <BODY><br><h3>20th June 2010</h3>
            <ul>
                <p>Detail line 1.<br>            Detail Line 2</p>
            </ul><br><h3>18th June 2010</h3>
            <ul>
                <p>Some more details</p>
            </ul>
        </BODY>
    </HTML>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to use JSTL but have the following problem: Index.xhtml page: <?xml version=1.0 encoding=UTF-8?>
I have some problem when unmarshaling a .xml at a web service using JAXB.
I have one problem , I want to get some data from XML file
I have some problem with my code public IQueryable<PageItems> GetPageById(Guid Id) { var xml
I have an xml document that I am trying to style with xsl. The
I have a problem with WPF and XML. What I am trying to do
I have been trying to use the SAX parser on Android to display some
I have been trying to figure this problem out without asking for help, but
Hello I have a ListFragment that fetches some data from the net and then
I have a simple problem with XML got from database. Now, this XML can

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.