Bog
Bog

Reputation: 153

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

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?

Upvotes: 15

Views: 39227

Answers (2)

Bill Ingram
Bill Ingram

Reputation: 1172

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

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

Hope this helps

Upvotes: 36

Bala R
Bala R

Reputation: 108967

Try this

substring(/node,1,10)

Reference for substring fn.

Upvotes: 5

Related Questions