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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:03:03+00:00 2026-06-14T12:03:03+00:00

I am totally new to xml and xsl so I am having some difficulties

  • 0

I am totally new to xml and xsl so I am having some difficulties to make my xml file look the way I wanted it to be. Basically the problem is that the table shows up correctly with all the stuff inside but the contents of the xml are also shown after the table. So i always have a table followed by all the data from xml. And i am testing my xml file on Firefox 16.0.2.

Here is a portion of my xml file.

<root>
  <name id = "content_here">
    <first> Cathy </first>
    <last> Claires </last>
  </name>
  ... more names down here
</root>

and I am trying to display it in a tabular format on Firefox and this is what I did for the xsl file.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html"/>
    <xsl:template match="root">
      <html>
       <body>
         <table>
           <tr>
             <th> id </th> 
             <th> first name </th> 
             <th> last name </th>
           </tr>
           <xsl:for-each select="name"> 
            <tr>
             <td> <xsl:value-of select="@id"/> </td>
             <td> <xsl:value-of select="first"/> </td>
             <td> <xsl:value-of select="last"/> </td>
           </tr>
           </xsl:for-each>  
</table>        

<xsl:apply-templates/>
</body>
</html>
</xsl:template>
   </xsl:stylesheet>

Anyone can give me a hint on how to get rid of the extra content after my table? Thank you!

  • 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-14T12:03:05+00:00Added an answer on June 14, 2026 at 12:03 pm

    The xsl:apply-templates instruction causes all the node children of your template context (here the root element) to be slung through the built-in templates. Removing it from your stylesheet should remove the content.

    Note there’s a better way of doing this though actually using the xsl:apply-templates rule.

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="html"/>
      <xsl:template match="root">
        <html>
          <body>
            <table>
              <tr>
                <th> id </th> 
                <th> first name </th> 
                <th> last name </th>
              </tr>
              <xsl:apply-templates/>
            </table>        
          </body>
        </html>
      </xsl:template>
    
      <xsl:template match="name"> 
        <tr>
          <td> <xsl:value-of select="@id"/> </td>
          <td> <xsl:value-of select="first"/> </td>
          <td> <xsl:value-of select="last"/> </td>
        </tr>
      </xsl:template>
    </xsl:stylesheet>
    

    Here xsl:apply-templates is used to apply template matching to the children of root inside your table. When a name element is matched, a tr is created. This is generally better practice than using xsl:for-each.

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

Sidebar

Related Questions

I'm totally new to android programming. I can see that this problem has been
I'm basically taking fileA.xml, grabbing nodes from totally distinct parts of the file, and
I have a file which is an XML representation of some data that is
Totally new to Capistrano. I have a local git repository that I want to
im totally new when it comes to trying to make HTML code. I was
I'm totally new to AWS. I managed to have an instance that runs PHPMyAdmin.
I'm totally new in OpenCV so hopefully that's not a too stupid question. As
i have the following Problem - first of all i'm totally new to Flex.
I've been given some XML files that don't quite have a proper schema (I
I'm totally new to MEF and wanted to use it in a project I'm

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.