Home Forums XMetaL Tips and Tricks Script Example: Word Count Feature Reply To: Script Example: Word Count Feature


Reply to: Script Example: Word Count Feature

Word-counting is one of those highly entertaining tasks for which 37 people will probably give you 37 different requirements.  This is an elegant and useful little bit of script, but it has problems.  For example, most of us would probably agree that the following bit of XML contains three words, but this script will say it has only one:

  • Äpfel
  • Bananen
  • Birnen

Another approach to word-counting is to walk the DOM tree counting words per node.  Maybe I'll post a script like that here soon, unless Derek or someone else beats me to it…