Iterating tags using XSLT -


i have xml structures below,

<namelist> <name>name01</name> <name>name02</name> <name>name03</name> <name>name04</name> </namelist>

how iterate on child tags of namelist , display them using xslt's xsl:for-each? ouput should

name01
name02
name03
name04

thanks

there no real need use xsl:for-each. can template matching favoured approach in xslt.

you need 1 template match namelist element, can output 'containing' elements want, , start selecting child elements

  <xsl:template match="namelist">      <table>          <xsl:apply-templates select="name" />      </table>   </xsl:template> 

then have template matching name element, output in whatever format want. example

  <xsl:template match="name">     <tr>       <td>          <xsl:value-of select="." />       </td>     </tr>   </xsl:template> 

try xslt starters:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">   <xsl:template match="namelist">      <table>          <xsl:apply-templates select="name" />      </table>   </xsl:template>   <xsl:template match="name">     <tr>       <td>          <xsl:value-of select="." />       </td>     </tr>   </xsl:template> </xsl:stylesheet> 

if did want more formatting or outputting elements, need have mentioned in question. thanks!


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -