Solution 1 :

As you said:

Any pointer will be very helpful

This minimal XSLT stylesheet is to get you started:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns_xsl=""
    exclude-result-prefixes="xs" version="2.0">
  <xsl:output method="html" encoding="UTF-8" indent="yes"/>
  <xsl:template match="/">
        <xsl:apply-templates select="/root/dq"/>
  <xsl:template match="row">
  <xsl:template match="row/child::*">

It will produce the following HTML table structure

    <td>Test 1</td>
    <td>Test 2</td>
    <td>Test 21</td>      
    <td>Test 22</td>

Problem :

I am new to XSLT. I am trying the parse the below XML and extract the values for each <row> element. There could be any number of child <row> elements under <row>, but I will have the names of the fields under <row>. Is there a way to loop and print this in a table using XSLT? Any pointer will be very helpful.

      <rowa>Test 1</rowa>
      <rowb>Test 2</rowb>
      <rowa>Test 21</rowa>
      <rowb>Test 22</rowb>

I am trying to get an HTML table, which will be rendered like:

Test 1 
Test 2
Test 21 
Test 22


Comment posted by Yitzhak Khabinsky

Please edit your post and add desired output based on the input XML. Also, what did you try to do? What is not working? Overall, you need to provide a minimal reproducible example.

Comment posted by here

As Yitzhak rightly points out SO users are encouraged to provide a Minimal Reproducible Example, a reprex. You can find out how to do so

Comment posted by michael.hor257k

What if there is

Comment posted by Thomas Hansen

@michael.hor257k — Good point! Changed the last template to make it a bit more robust.