Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

Problem with nested for-each in xslt

$
0
0

Hi,

I have the following XML and .xslt files.

I'm trying to execute a nested for-each loop. First, I need to iterate on the "modules" nodes, and then iterate on the "data" nodes in each module. The problem is, the for-each for the "data" works, but the for-each for the"modules" doesn't.

What am I missing?

Thanks.

Here is the .xslt

<xsl:template match="GModules"><xsl:value-of select="@text"/><xsl:for-each select="/modules"><table><xsl:for-each select="*/data"><tr><td><xsl:value-of select="label"/></td><td><xsl:value-of select="value"/></td></tr></xsl:for-each></table></xsl:for-each></xsl:template>

Here is the XML:

<GModules text="Modules"><modules text="Device"><data><label>ID</label><value>1</value></data><data><label>SN</label><value>0</value></data><data><label>SW</label><value>1</value></data><data><label>HW</label><value>E</value></data></modules><modules text="Sensor"><data><label>ID</label><value>2</value></data><data><label>SN</label><value>1</value></data><data><label>SW</label><value></value></data><data><label>HW</label><value></value></data></modules><modules text="Connector"><data><label>ID</label><value>3</value></data><data><label>SN</label><value>9</value></data><data><label>SW</label><value></value></data><data><label>HW</label><value></value></data></modules>

</GModules>



Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>