請問,我想知道我們如何從xsl文件中獲得java項目列表。如何從XSL獲取項目列表
這是文件的一個例子:
//catalog.xml
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
</cd>
<cd>
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<country>USA</country>
</cd>
</catalog>
// XSL文件中我有:
<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>
所以現在我該怎麼辦如果我想獲得java類中所有標題的列表?
換句話說,我想得到(在java類中)包含3個值的列表:帝國滑稽表演,隱藏你的心臟和最偉大的命中。
感謝您提前
謝謝你的迴應。事實上,我是XSLT新手,所以我沒有太多的如何解決這個問題 – Samounas
爲了在Java中提取這些值,可以簡單地使用JAXP/JAXB。 –
謝謝。請你能給我一個這樣的代碼的例子嗎? – Samounas