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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:10:13+00:00 2026-05-15T13:10:13+00:00

i want to transform some xml into HTML that has the following format: <TR><TD>

  • 0

i want to transform some xml into HTML that has the following format:

<TR><TD> col1 <TD> col2 <TD> col3 </TR>

Note: The output is HTML, complete with optional closing tags omitted. This is the problem, and the reason the question exists.

A snippet of the XSL i’m using is:

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output 
    doctype-system='http://www.w3.org/TR/html4/strict.dtd'
    doctype-public='-//W3C//DTD HTML 4.01//EN'
    indent='yes'
    method='html'
    />
   ...
   <xsl:for-each select="/">  
      <TR><TD><xsl:value-of select="col1"/><TD><xsl:value-of select="col2"/><TD><xsl:value-of select="col3"/></TR>
   </xsl:for-each>

You can see that the guts of the XSL matches my desired HTML (wrapped for easy reading):

<TR>  <TD><xsl:value-of select="Column1"/>
      <TD><xsl:value-of select="Column2"/>
      <TD><xsl:value-of select="Column3"/> </TR>

Note: Those of you who know the error i’m getting from the XSLT: hopefully already know the answer.

When presented with my XSL (which, don’t forget, is a form of xml), i get the non-well formed error:

End tag ‘TR’ does not match the start tag ‘TD’.

This makes perfect sense. Indeed:

<TD><xsl:value-of select="Column3"/> </TR>

i do not close the TD element before closing the TR. So the question is:

How can i transform xml into HTML, given that HTML is not xml?

See also

  • HTML: Include, or exclude, optional closing tags?
  • XSLT: Transforming into non-xml content?
  • Omitting optional tags of html

Update one

It has been suggested that one could simply include the closing tags anyway, in order to make the XSL validate (shown wrapped for easy reading):

<TR>    <TD><xsl:value-of select="col1"/></TD>
        <TD><xsl:value-of select="col2"/></TD>
        <TD><xsl:value-of select="col3"/></TD>   </TR>

then, by using xsl:output method='html', the final HTML content would have the </TD> tags magically omitted. Except it doesn’t work:

<TR><TD>col1</TD><TD>col2</TD><TD>col3</TD></TR>

Update two

It has been suggested that i give up, don’t bother asking this question, and just include the optional closing tags. That’s possible, but that’s not my question. Also, the “solution” doesn’t work for elements where the closing tag is forbidden, e.g.:

<BR/>

or

<BR></BR>

How would i include a <BR> element in my HTML output, given that it is forbidden in HTML to close a <BR> element.

  • 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-15T13:10:14+00:00Added an answer on May 15, 2026 at 1:10 pm

    Here’s one way to do this:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
    
     <xsl:template match="/*">
       &lt;TR>&lt;TD><xsl:value-of select="col1"/>&lt;TD><xsl:value-of select="col2"/>&lt;TD><xsl:value-of select="col3"/>&lt;/TR>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the following XML document:

    <t>
     <col1>1</col1>
     <col2>2</col2>
     <col3>3</col3>
    </t>
    

    the wanted result is correctly produced:

       <TR><TD>1<TD>2<TD>3</TR>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using an XsltCompiledTransform to transform some XML into a fragment of HTML (not
I have an XML document (in a .net C# web app) that I want
I’m working on a site In that site some pages gets data from XML
I have a function that grabs an XML document and transforms it according to
I need a daemon that turns RSS into email. It should have an API
I am having trouble transforming particular characters from an XML feed into XHTML. I
I'm editing books/articles in HTML. These texts were printed once and I scan them,
I'm trying to make a meta-language for writing markup code (such as xml and
I've got a .jsp file that is working fine. It's maybe a bit special

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.