Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I would like to know how to count the number of characters of text in XSLT. Thank you very much!
Hi,
You want to count umber of characters or display a certain amount of characters with xslt?
//fuji
To find out the number of characters in text, you can use the "string-length" function.
<xsl:value-of select="string-length(propertyAlias)" />
Where 'propertyAlias' is the name of your property.
Cheers, Lee.
Thank you very much brother! Can you give me your email, so we can contact you?But is very annoying, I'd appreciate it a lot, thanks again!
My inbox is always open... http://j.mp/leeeeee
Hi, how would you go about doing this in Razor? I wan't to count the words in my bodyText and display it so visitors can see how long the text is. Thanks
Hi Niklas,
Did you want a character count, or a word count?
For character count, it a simple string length:
@Model.Content.GetPropertyValue("bodyText").Length
For a word count, you'd need to define the word boundaries. A quick and dirty would be to split the string by spaces, then count the items:
@Model.Content.GetPropertyValue("bodyText").Split(' ').Count()
For more advanced techniques, check this link: http://www.dotnetperls.com/word-count
Cheers, - Lee
Great, thanks Lee!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Count the number of characters of text in XSLT
I would like to know how to count the number of characters of text in XSLT. Thank you very much!
Hi,
You want to count umber of characters or display a certain amount of characters with xslt?
//fuji
To find out the number of characters in text, you can use the "string-length" function.
Where 'propertyAlias' is the name of your property.
Cheers, Lee.
Thank you very much brother! Can you give me your email, so we can contact you?But is very annoying, I'd appreciate it a lot, thanks again!
My inbox is always open... http://j.mp/leeeeee
Hi, how would you go about doing this in Razor? I wan't to count the words in my bodyText and display it so visitors can see how long the text is. Thanks
Hi Niklas,
Did you want a character count, or a word count?
For character count, it a simple string length:
For a word count, you'd need to define the word boundaries. A quick and dirty would be to split the string by spaces, then count the items:
For more advanced techniques, check this link: http://www.dotnetperls.com/word-count
Cheers,
- Lee
Great, thanks Lee!
is working on a reply...