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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:53:47+00:00 2026-05-28T22:53:47+00:00

Let’s assume I have a simple XML file: <data> <text>Hello world!&lt;br&gt;Nice to see you

  • 0

Let’s assume I have a simple XML file:

<data>
  <text>Hello world!&lt;br&gt;Nice to see you all!&lt;br&gt;Goodbye!</text>
</data>

Now I want to replace all &lt;br&gt; strings with &#10; strings so the result should be e.g.:

<transformed>
  <text>Hello world!&#10;Nice to see you all!&#10;Goodbye!</text>
</transformed>

How do I do this?

XSL replace functionality is easy to implement (e.g. in http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx) but the tricky part is to get the XSL transformer to output those &#10; strings.. I either get invisible normal linefeed or &amp;#10;

Perfect answer would be an XSL template which does the trick.

  • 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-28T22:53:48+00:00Added an answer on May 28, 2026 at 10:53 pm

    Use:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" indent="yes"/>
    
      <xsl:template match="/data">
        <transformed>
          <text>
            <xsl:call-template name="string-replace-all">
              <xsl:with-param name="text" select="text" />
              <xsl:with-param name="replace">&lt;br&gt;</xsl:with-param>
              <xsl:with-param name="by">&amp;#10;</xsl:with-param>
            </xsl:call-template>
          </text>
        </transformed>
      </xsl:template>
    
      <xsl:template name="string-replace-all">
        <xsl:param name="text" />
        <xsl:param name="replace" />
        <xsl:param name="by" />
        <xsl:choose>
          <xsl:when test="contains($text, $replace)">
            <xsl:value-of select="substring-before($text, $replace)" />
            <xsl:value-of select="$by" disable-output-escaping="yes" />
            <xsl:call-template name="string-replace-all">
              <xsl:with-param name="text" select="substring-after($text,$replace)" />
              <xsl:with-param name="replace" select="$replace" />
              <xsl:with-param name="by" select="$by" />
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$text" />
          </xsl:otherwise>
        </xsl:choose>
      </xsl:template>
    
    </xsl:stylesheet>
    

    output:

    <transformed>
      <text>Hello world!&#10;Nice to see you all!&#10;Goodbye!</text>
    </transformed>
    

    NB!:

    Set disable-output-escaping attribute to yes

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

Sidebar

Related Questions

Let's say I have the string: hello world; some random text; foo; How could
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Let's say I'm building a data access layer for an application. Typically I have
Let's say we have a simple function defined in a pseudo language. List<Numbers> SortNumbers(List<Numbers>
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
Let's say I have this code: <p dataname=description> Hello this is a description. <a
Let say I have some code HTML code: <ul> <li> <h1>Title 1</h1> <p>Text 1</p>
Let's say i have input 22365.2588 in my Edit Text. I want to change
Let's say I have this MySQL table: OK.. see the type field? Type 0

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.