0

I want to substring a particular sentence in XSLT so I use below function and it works fine.

<xsl:value-of select='substring("This is My String",2,6)'/> 

But what I want to do is provide a "This is My String" as a value from XSLT expression like below.

<xsl:value-of select='substring(<xsl:value-of select="searchpage/header/para[2]/text"/>,2,6)'/>

If I do this it gives me below error.

XML Parsing Error: not well-formed

How can i fix this?

1 Answer 1

2

Just like this :

<xsl:value-of select='substring(searchpage/header/para[2]/text, 2, 6)'/>

You can use the value retrieved by your XPath expression directly in the substring() function.

Note: in your XPath, you expect to have a <text> tag within the <para>. Hope you don't confuse with the XPath text().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.