Search

hi,

I want to add all output which are in numbers (e.g: 5+3+2 ) in a particular for-each loop.. any one tell the correct way to add n numbers in for-each loop..

thanks

Without seeing your XML and XSLT it's difficult to be more specific... but within an xsl:for-each it is difficult. You could use recursive templates instead:

Or if your numbers (5, 3, 2) are in a consistent element in your XSLT then you can use this to sum all instances of the element.

<xsl: value-of select="sum(/xpath/to/this/element)" />

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details