Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl: nesting for-each 1

Status
Not open for further replies.

raghu3

Programmer
Dec 19, 2005
96
US
I have the following xml:
<userattribute>
<attribute>
<name> </name>
<value> </value>
<value2> </value2>
</attribute>

<attribute>
<name> </name>
<value> </value>
<value> </value>
<value2> </value2>
</attribute>
</userattribute>

One attribute can have multiple values. Here is the xls to display in a small html table:

<?xml version="1.0" encoding="ISO-8859-1"?>

<html xsl:version="1.0" xmlns:xsl=" xmlns="
<body style="font-family:Arial,helvetica,sans-serif">



<table border="1">
<tr>
<th align="left">Attribute</th>
<th align="left">Value</th>
<th align="left">Value2</th>
</tr>

<xsl:for-each select="userattribute/attribute">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="value"/></td>
<td>
<table>
<xsl:for-each select="value">
<tr><td><xsl:value-of select="value"/></td></tr>
</xsl:for-each>
</table>

</td>
<td><xsl:value-of select="value2"/></td>


</tr>
</xsl:for-each>

</table>


</body>
</html>


This displays only 1 value of the multiple ones!!

I tried a foreach within the value: does not show even 1 value.

what am I missing here. I am fairly new to xml and this site has been very helpful for me to get started.



Thanks
raghu
 
found it!
Code:
<xsl:for-each select="value">
                        <tr><td><xsl:value-of select="."/></td></tr>
                    </xsl:for-each>
 
That worked.
Thanks a lot.
I give you a star.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top