【发布时间】:2011-04-07 09:06:33
【问题描述】:
假设我有这个 xml:
<college>
<student>
<name>amit</name>
<file>/abc/kk/final.c</file>
<rollno>22</rollno>
</student>
<student>
<name>sumit</name>
<file>/abc/kk/up.h</file>
<rollno>23</rollno>
</student>
<student>
<name>nikhil</name>
<file>/xyz/up.cpp</file>
<rollno>24</rollno>
</student>
<student>
<name>bharat</name>
<file>/abc/kk/down.h</file>
<rollno>25</rollno>
</student>
<student>
<name>ajay</name>
<file>/simple/st.h</file>
<rollno>27</rollno>
</student>
</college>
我在“.xsl”中使用 for-each 来显示节点的所有条目,但我只想显示那些文件名以“/abc/kk”开头的节点的条目,因为我是新手到 xslt..
请给我解决方案。
我正在使用:
<xsl:for-each select="college/student">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="file"/></td>
<td><xsl:value-of select="rollno"/></td>
</tr>
【问题讨论】:
-
请提供格式正确的 XML,以便我们更好地理解您的问题
-
好问题,+1。有关使用 XSLT 的基本功能(例如模板和推送样式处理)的完整、简短且简单的解决方案,请参阅我的答案。提供了详细的解释。
标签: xslt