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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:42:18+00:00 2026-06-10T17:42:18+00:00

I have an xml similar to the one as follows <DataSet1> <Table1> <Column1>Value111</Column1> <Column2>Value112</Column2>

  • 0

I have an xml similar to the one as follows

<DataSet1>
    <Table1>
        <Column1>Value111</Column1>
        <Column2>Value112</Column2>
    </Table1>
    <Table1>
        <Column1>Value121</Column1>
        <Column2>Value122</Column2>
    </Table1>
    <Table1>
        <Column1>Value131</Column1>
        <Column2>Value132</Column2>
    </Table1>
    <Table2>
        <Column1>Value211</Column1>
        <Column2>Value212</Column2>
    </Table2>
    <Table2>
        <Column1>Value221</Column1>
        <Column2>Value222</Column2>
    </Table2>
    <Table2>
        <Column1>Value231</Column1>
        <Column2>Value232</Column2>
    </Table2>
</DataSet1>

Where Table1 and Table2 are added dynamically in the dataset. So there can be n number of tables in dataset as Tablen.

I want to write xsl which produces the html as follows

Table1
<table>
    <tr>
        <td>Value111</td>
        <td>Value112</td>
    </tr>
    <tr>
        <td>Value121</td>
        <td>Value122</td>
    </tr>
    <tr>
        <td>Value131</td>
        <td>Value132</td>
    </tr>   
</table>

Table2
<table>
    <tr>
        <td>Value211</td>
        <td>Value212</td>
    </tr>
    <tr>
        <td>Value221</td>
        <td>Value222</td>
    </tr>
    <tr>
        <td>Value231</td>
        <td>Value232</td>
    </tr>
</table>

Is there any way to select xsl template as select=”DataSet1/Table*” which can match with any table and iterate the structure?

Please 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-06-10T17:42:20+00:00Added an answer on June 10, 2026 at 5:42 pm

    This transformation:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:key name="kTableByName" match="*[starts-with(name(),'Table')]"
      use="name()"/>
    
     <xsl:template match=
      "*[generate-id()
        =
         generate-id(key('kTableByName', name())[1])
         ]">
      <xsl:value-of select="concat('&#xA;', name(), '&#xA;')"/>
      <table>
       <xsl:apply-templates select="key('kTableByName', name())" mode="inGroup"/>
      </table>
     </xsl:template>
    
     <xsl:template match="*[starts-with(name(),'Table')]" mode="inGroup">
      <tr>
        <xsl:apply-templates select="*" mode="inGroup"/>
      </tr>
     </xsl:template>
    
     <xsl:template match="*[starts-with(name(),'Table')]/*" mode="inGroup">
      <td>
        <xsl:value-of select="."/>
      </td>
     </xsl:template>
     <xsl:template match="text()"/>
    </xsl:stylesheet>
    

    when applied on the provided XML document:

    <DataSet1>
        <Table1>
            <Column1>Value111</Column1>
            <Column2>Value112</Column2>
        </Table1>
        <Table1>
            <Column1>Value121</Column1>
            <Column2>Value122</Column2>
        </Table1>
        <Table1>
            <Column1>Value131</Column1>
            <Column2>Value132</Column2>
        </Table1>
        <Table2>
            <Column1>Value211</Column1>
            <Column2>Value212</Column2>
        </Table2>
        <Table2>
            <Column1>Value221</Column1>
            <Column2>Value222</Column2>
        </Table2>
        <Table2>
            <Column1>Value231</Column1>
            <Column2>Value232</Column2>
        </Table2>
    </DataSet1>
    

    produces the wanted, correct result:

    Table1
    <table>
       <tr>
          <td>Value111</td>
          <td>Value112</td>
       </tr>
       <tr>
          <td>Value121</td>
          <td>Value122</td>
       </tr>
       <tr>
          <td>Value131</td>
          <td>Value132</td>
       </tr>
    </table>
    Table2
    <table>
       <tr>
          <td>Value211</td>
          <td>Value212</td>
       </tr>
       <tr>
          <td>Value221</td>
          <td>Value222</td>
       </tr>
       <tr>
          <td>Value231</td>
          <td>Value232</td>
       </tr>
    </table>
    

    Explanation:

    Proper use of the Muenchian Grouping method.

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

Sidebar

Related Questions

I have a HTML/XML document similar to the following. There can be one or
I have a xml structure similar to below one: <test> <test1>test1 value</test1> </test> Now
Hi I have big xml file which has a structure similar to the one
I have a XML response from an Ajax REST call. Similar to the one
I Have XML similar to this(omitted parts for brevity): <uformrecord> <state>Submitted</state> <created>2012-06-19T11:31:54</created> <updated>2012-06-19T11:32:13</updated> <id>53225sas3c1-d727-42cd-93a6-97cd778e5ee9</id>
I have some xml similar to this: <?xml version=1.0 encoding=utf-8 ?> <data> <resources> <resource
I have an XML layout similar to this (the XML and code is a
I have an XML document with a section similar to the following: <release_list> <release>
I have an array of System.Xml.XmlNode with data similar to this: [0] = <Node1
I have xml as follows <Search> <Term /> <And /> <Term /> <And />

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.