Reputation: 3035
I have to work on XML files on which i won't know the names of the nodes. All i know is that the structure will be the same between the different files
The structure will be the above one
<root>
<node1>
<node2>
</node2>
</node2>
</root>
I have to make an XSLT file for building an HTML page that will display the content of the nodes.
For now i have this piece of code
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="employe.css"/>
</head>
<body>
<table>
<tr>
<th>ID Source</th>
<th>Nom</th>
<th>Prénom</th>
<th>Age</th>
<th>Adresse</th>
<th>Code Postal</th>
<th>Ville</th>
<th>Telephone</th>
<th>Poste</th>
</tr>
<xsl:apply-templates/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="child::*">
<tr>
<xsl:apply-templates/>
</tr>
</xsl:template>
<xsl:template match="">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
I succeeded in selecting the first and the second level nodes but don't know how to select the third.
Thanks for help
Upvotes: 1
Views: 104
Reputation: 52878
You could try changing the match="/"
to match="/*"
and adding these two templates:
<xsl:template match="*[*]">
<tr>
<xsl:apply-templates/>
</tr>
</xsl:template>
<xsl:template match="*[not(*)]">
<td><xsl:value-of select="."/></td>
</xsl:template>
Upvotes: 2