0
votes

How to visualize the following XML

<Root>
 <name1> 
  <node1>  some text  </node1> 
  <node2>  <node22/>  <node23/>  </node2>  
 </name1> 
 <name2>   
  <node1>  some text  </node1> 
  <node2>  <node22/>  <node23/>  </node2>  
 </name2>   
</Root>

The name of these node1, node12, node13, Root nodes are known, but name1, name2, etc. are unknown in advance.

The desired output should be a set of two tables for each name, one for node1 and other for node2.

My problem is that I can't iterate over nameX because I don't know the exact name of the node. In the example above I used nameX but it can be any valid name.

1
Could you add the expected output of your example?Filburt

1 Answers

1
votes

The desired output should be a set of two tables for each name, one for node1 and other for node2.

Try it this way:

XSLT 1.0

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/Root">
    <xsl:copy>
        <xsl:for-each select="*">
            <table>
                <!-- build your table here -->
            </table>
        </xsl:for-each>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>