<xsl:for-each select= 取嵌套节点则么写
<root>
<techs>
<tech>
<title>aaa</title>
<groups>
<group>
<name>group1</name>
</group>
<group>
<name>group2</name>
</group>
</groups>
</tech>
<tech>
<title>bbb</title>
<groups>
<group>
<name>group1</name>
</group>
</groups>
</tech>
</techs>
</root>
现在我想把每个tech节点的内容都列出来,包括title和groups里的每个group的name
怎么取到group name的值?
<xsl:template match="/">
<xsl:for-each select="root/techs/tech">
<xsl:value-of select="title" /> // 这个title可以取到值
<xsl:for-each select="groups/group"> // select表达式该如何写???
<xsl:value-of select="name" /> // 这里name取不到
</xsl:for-each>
</xsl:for-each>
</xsl:template>
[解决办法]
不清楚你的为什么取不到,我的可以取到:
xml:
<?xml-stylesheet type="text/xsl" href="transfer_test.xslt" ?>
<root>
<techs>
<tech>
<title>aaa</title>
<groups>
<group>
<name>group1</name>
</group>
<group>
<name>group2</name>
</group>
</groups>
</tech>
<tech>
<title>bbb</title>
<groups>
<group>
<name>group1</name>
</group>
</groups>
</tech>
</techs>
</root>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:template match="/">
<xsl:for-each select="root/techs/tech">
<span>
<xsl:value-of select="title"/>
</span>
<xsl:for-each select="groups/group">
<br />
<span>
<xsl:value-of select="name"/>
</span>
</xsl:for-each>
<br />
<br />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>