Tintin81
Tintin81

Reputation: 10207

How to get the first letter of an XML attribute with XSLT?

I have this XML:

<entry>
  <title handle="foo">Foo</title>
</entry>

How can I get the first letter of the handle attribute using XSLT 1.0?

Thanks for any help.

Upvotes: 2

Views: 1211

Answers (1)

Jukka Matilainen
Jukka Matilainen

Reputation: 10198

You can use the substring XPath function.

For example, the following XPath expression will evaluate to 'f' for your example XML.

substring(/entry/title/@handle, 1, 1)

Upvotes: 3

Related Questions