我想通過xslt顯示一個XML標籤屬性,但我很難搞清楚它。用xslt顯示xml標籤屬性
我的XML文件看起來與此類似:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="results.xsl"?>
<search command="grep -n -i -I htm C:\firebreath\*">
<match number="1">
<filename>C:\firebreath\CMakeLists.txt </filename>
<linenum>10 </linenum>
<matchstring># http://www.gnu.org/licenses/lgpl-2.1.html</matchstring>
</match>
</search>
我的XSLT文件看起來像這樣:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>grep matches </h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>filename</th>
<th>line number</th>
<th>match string</th>
</tr>
<xsl:for-each select="search/match">
<tr>
<td><xsl:value-of select="filename"/></td>
<td><xsl:value-of select="linenum"/></td>
<td><xsl:value-of select="matchstring"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
我想顯示的搜索標籤的命令部分在我開始解決其餘的問題之前。有沒有辦法做到這一點?如果是這樣,怎麼樣?一個搜索不轉了什麼特別相關的...
問得好,+1。查看我的答案,獲取完整而簡短的解決方案。 :) – 2010-11-08 19:08:37