| | |
How I could fetch first three character from a string variable
Please support our XML, XSLT and XPATH advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
1
#3 Oct 21st, 2009
•
•
•
•
Hi,
How I could fetch first three character from a string variable.
Say for I fetched a variable message="ABCtest" .... now I want to test that the first three character matches ABD or not .. How I could code to achieve in xslt?
Cheers
Manish
Let's consider the following example
XML, XSLT and XPATH Syntax (Toggle Plain Text)
<?xml version="1.0" encoding="UTF-8"?> <abc> <def> </def> <ghi> <jkl>ABCdef</jkl> </ghi> <jkl/> </abc>
I want to print ABCdef if it contain ABC in the first three letters....
XML, XSLT and XPATH Syntax (Toggle Plain Text)
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="jkl"> <xsl:if test="substring(.,1,3)='ABC'"> <xsl:value-of select="."/> </xsl:if> </xsl:template> </xsl:stylesheet>
Hope you will get the answer.
Regards.
![]() |
Similar Threads
- Reading first character in a string (C++)
- How to Retrieve THAI Language Data From SQL Server 2000 to string variable (Visual Basic 4 / 5 / 6)
- changing from char type to string type (Java)
- the middle character of a string (C++)
- Search for a string in a variable--- (PHP)
- Problem with string variable in void prnt function (C++)
- Finding the Most Common Character in a String (Java)
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: Xpath expression
- Next Thread: XML Feed Problem with £ and ' any ideas.... anyone???
| Thread Tools | Search this Thread |






