更新:失敗的情況下XML轉換時,標籤包含編碼字符
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd>
<title>Empire & Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
<catalog>
<cd>
<title>Empire & Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
您好我有下面的XML
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
以下XSL翻譯上述
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
現在翻譯好了。但是,如果我將XML標記值更改爲包含&
或等編碼字符,則我無法獲得結果
如何避免這些字符?
你能向我們展示實際失敗的樣本輸入嗎?並告訴我們究竟是如何失敗? – 2013-04-22 05:07:23
如果您在輸入中有&,它應該與您創建的XSLT一起使用。 – 2013-04-22 05:11:22
<?XML版本= 「1.0」 編碼= 「ISO-8859-1」?> \t \t \t 帝國&滑稽 \t \t 鮑勃迪倫 \t \t 美國 \t \t 哥倫比亞 \t \t 10.90 \t \t \t –
user778930
2013-04-22 05:12:16