|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi,
i'm having a huge problem getting my xml in a table with xsl ! this is my xml, <?xml version="1.0" encoding="ISO-8859-15"?> <objects> <object avenue="auctions" id="2809755"> <room id="1401"/> <title>Kachel op aardgas Wellstraler 7,60 kW</title> <language>nl</language> <image id="1755466"/> </object> <object avenue="auctions" id="2913991"> <room id="1401"/> <title>SPLINTERNIEUWE MAZOUTTANK</title> <language>nl</language> <image id="1820070"/> </object> <object avenue="auctions" id="3004679"> <room id="1401"/> <title>magnifique feux au bois</title> <language>fr</language> <image id="1760827"/> <image id="1760828"/> </object> <object avenue="auctions" id="3004679"> <room id="1401"/> <title>magnifique feux au bois</title> <language>fr</language> <image id="1760827"/> <image id="1760828"/> </object> <object avenue="auctions" id="2913991"> <room id="1401"/> <title>SPLINTERNIEUWE MAZOUTTANK</title> <language>nl</language> <image id="1820070"/> </object> </objects> Now I have to get only the images from the nodes with language=nl into a table with 3 cells / row. Is there a way to count how many nodes i have with language=nl and then loop through them ? Or maybe another way to do this. Every suggestion is welcome ! thanks, wendy |
|
#2
|
|||
|
|||
|
hope this helps u
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl utput method="html" indent="no" encoding="utf-8"/><xsl:template match="/"> <xsl:variable name="start" expr="'<tr>'"/> <xsl:variable name="end" expr="'</tr>'"/> <table border="1" cellpadding="0" cellspacing="0" width="300"> <xsl:for-each select="//objects/object[language='nl']"> <xsl:if test="position() mod 3=1"> <xsl:value-of select="$start" disable-output-escaping="yes"/> </xsl:if> <td width="100"> <xsl:value-of select="image/@id"/></td> <xsl:if test="position() mod 3=0"> <xsl:value-of select="$end" disable-output-escaping="yes"/> </xsl:if> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> ==================== with regards niha |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Getting specific nodes displayed in a table using xsl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|