Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xsl: How to select the first x number of characters in a node?

Tags:

xml

xslt

I have the following node in a XML doc:

<node>This is some text.</node>

I want to select the first 10 characters of the text. How can I do this?

like image 625
Bog Avatar asked May 03 '11 19:05

Bog


2 Answers

You can use the substring function to select the first 10 characters.

<xsl:value-of select="substring(node/text(),1,10)"/>

Hope this helps

like image 195
Bill Ingram Avatar answered Oct 05 '22 12:10

Bill Ingram


Try this

substring(/node,1,10)

Reference for substring fn.

like image 5
Bala R Avatar answered Oct 05 '22 12:10

Bala R