XML : Count the number of times a player play a different difficult level

I have a xml and xslt files like below. And Im showing in a table the gamename and the player name. But now Im trying to do one thing and Im not see how.

I want to show how many times a player played a game in a novice, easy, medium, hard, legend level and the total. For example I want each row like this:

  GameName | Player Name | NoviceLevels | EasyLevels | MediumLevels | HardLevels | Total    

I already try a lot of alternatives but Im not having success put this working like this. Do you see how to achieve this?

  <games>    <game>      <gamename>GameTitle 1</gamename>      <players>        <player>            <playername>John</playername>            <difficultlevel>Novice</difficultlevel>            <duration>130</duration>        </player>        <player>          <playername>John</playername>          <difficultlevel>Easy</difficultlevel>          <duration>210</duration>        </player>        <player>          <playername>Zed</playername>          <difficultlevel>Medium</difficultlevel>          <duration>300</duration>        </player>      </players>    </game>  </games>    

And this xslt:

  <table>  <xsl:for-each select="//games">   <tr>     <th>GameName</th>     <th>Player</th>     <th>Beginner</th>     <th>Beginner</th>     <th>Medium</th>     <th>Hard</th>     <th>Legend</th>     <th>Total</th>   </tr>  <xsl:for-each select="game">   <tr>     <td><xsl:value-of select="gamename"/></td>     <td><xsl:value-of select="players/player/playername"/></td>     ....???   </tr>   </xsl:for-each>  </table>    

No comments:

Post a Comment