Reputation: 71
I have a XML like below:
<chap>
<CN>1</CN>
<CT>xxxx</CT>
</chap>
I would like to combine these two into a single element as below
<div class="chap-title">1 xxxx</div>
using XSLT
Upvotes: 0
Views: 1504
Reputation: 52858
I think the easiest way in XSLT 2.0 would be to use xsl:value-of
with a separator
attribute:
<xsl:template match="chap">
<div class="chap-title">
<xsl:value-of select="*" separator=" "/>
</div>
</xsl:template>
You could also change the select="*"
to select="CN|CT"
to only use the values of CN
and CT
or change the select="*"
to select="CN,CT"
to specify the values and the order.
Upvotes: 1