假設我有這樣的XML:如何使用xslt過濾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」顯示節點的所有條目,但我只想要顯示這些節點的條目僅在文件名以「/ 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,以便我們更好地理解您的問題 – 2011-04-07 09:07:56
好問題,+1。查看我的答案,獲得使用XSLT的基本功能(例如模板和推式處理)的完整,簡短易用的解決方案。提供了詳細的解釋。 – 2011-04-07 13:30:44