questo è l'xml
mentro questo è l'xsl:Codice PHP:<?xml version="1.0"?>
<?xml-stylesheet type='text/xsl' href='persona.xsl'?>
<dati>
<persona>
<nome>Mario</nome>
<cognome>Rossi</cognome>
<indirizzo>
<via>Via Roma</via>
<numero>36</numero>
<cap>12345</cap>
<comune>Genova</comune>
<provincia>Ge</provincia>
</indirizzo>
</persona>
<persona>
<nome>Giuseppe</nome>
<cognome>Verdi</cognome>
<indirizzo>
<via>Via Nizza</via>
<numero>6</numero>
<cap>123456</cap>
<comune>Milano</comune>
<provincia>MI</provincia>
</indirizzo>
</persona>
</dati>
esiste un modo col "for-each" di evitare di scrivere un <td><xsl:value-of select"nometag"></td> per ogni tag? in modo tale che se ho 200 tag non devo scrivere <td><xsl:value-of select"nometag"></td> 200 volte?Codice PHP:<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" version="4.0"/>
<xsl:template match="dati">
<html>
<head>
<title>persona.xml</title>
<style>
body
{
font-family: verdana;
}
</style>
</head>
<body>
<table border="1">
<tr bgcolor="#FFDEAD">
<td >Nome:</td>
<td>Cognome:</td>
<td>Via:</td>
<td>Numero civico:</td>
<td>Cap:</td>
<td>Comune:</td>
<td>Provincia:</td>
</tr>
<xsl:apply-templates select="persona"/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="persona">
<tr bgcolor="#fff8dc">
<td><xsl:value-of select="nome"/></td>
<td><xsl:value-of select="cognome"/></td>
<td><xsl:value-of select="indirizzo/via"/></td>
<td><xsl:value-of select="indirizzo/numero"/></td>
<td><xsl:value-of select="indirizzo/cap"/></td>
<td><xsl:value-of select="indirizzo/comune"/></td>
<td><xsl:value-of select="indirizzo/provincia"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>

Rispondi quotando
