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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:38:09+00:00 2026-05-13T19:38:09+00:00

I’m stuck on what I think should be simple thing to do. I’ve been

  • 0

I’m stuck on what I think should be simple thing to do. I’ve been looking around, but didn’t find the solution. Hope you will help me.

What I have is an XML element with an attribute that contains escaped HTML elements:

<Booking>    
  <BookingComments Type="RAM" comment="RAM name fred&lt;br/&gt;Tel 09876554&lt;br/&gt;Email fred@bla.com" />
</Booking>

What I need to get is parsed HTML elements and content from the @comment attribute to be a content of

element as follows:

<p>
  RAM name fred<br/>Tel 09876554<br/>Email fred@bla.com
<p>

Here is my XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" exclude-result-prefixes="xs fn" version="1.0">


<xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" 
    doctype-system="http://www.w3.org/TR/html4/loose.dtd" encoding="UTF-8" indent="yes" />

 <xsl:template name="some-template">
   <p>Some text</p>
   <p>
      <xsl:copy-of
        select="/Booking/BookingComments[lower-case(@Type)='ram'][1]/@comment"/>
   </p>     
 </xsl:template>
</xsl:stylesheet>

I’ve read that copy-of is a good way to restore escaped HTML elements back to proper elements. In this specific case, because it’s initially an attribute the copy-of translates it into attribute as well. So I get:

<p comment="RAM name fred<br/&gt;Tel 09876554<br/&gt;Email fred@bla.com"></p>

Which isn’t what I want.

If I use apply-templates instead of copy-of, as in:

<p>
  <xsl:apply-templates select="/Booking/BookingComments[lower-case(@Type)='ram'[1]/@comment"/>
</p>

I get p’s content simply as text, not restored HTML elements.

<p>RAM name fred&lt;br/&gt;Tel 09876554&lt;br/&gt;Email fred@bla.com</p>

I’m sure I’m missing something obvous. I would really appreciate any help and tips!

  • 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-13T19:38:09+00:00Added an answer on May 13, 2026 at 7:38 pm

    I would recommend using a dedicated template:

    <!-- check if lower-casing @Type is really necessary -->
    <xsl:template name="BookingComments[lower-case(@Type)='ram']/@comment">
      <p>
        <xsl:value-of select="." disable-output-escaping="yes" />
      </p>     
    </xsl:template>
    

    This way you could simply apply templates to the attribute. Note that disabling output escaping has the potential to generate ill-formed output.

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

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I am trying to understand how to use SyndicationItem to display feed which is
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.