Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL method for instring character from XML data

Status
Not open for further replies.

SilverStray

Programmer
Oct 25, 2001
47
AU
Hi,

Is there a way where I could get the first, or first 2 characters only of a certain data retrieved from XML data?
For example, my data is 'MN123445', and I only want to get the first 2 characters, 'MN', how do I do this in XSL?

thanks in advance!
 

XML:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <mynode>MN123445</mynode>
</root>
XSL:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
  <xsl:template match="/">
    <result>
      <xsl:value-of select="substring(root/mynode, 1, 2)"/>
    </result>
  </xsl:template>
</xsl:stylesheet>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top