How to get string length

XML to be used for our example:


Now use this xml in xslt as

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="">

<xsl:template match="/">

<xsl:template match="FoodItems">
  <table border="1" style="background-color:#cccc00">
      <th>Food Item</th>
      <th>String Length</th>
    <xsl:for-each select="FoodItems">  
      <td><xsl:value-of select="Name"/></td>
      <td><xsl:value-of select="string-length(Name)"/></td>



FoodItem String Length
Juice 5
Bread 5
Eggs 4

Categories: xslt 1.0

Tagged as: , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.