Link to home
Start Free TrialLog in
Avatar of frtools
frtoolsFlag for United States of America

asked on

Calculate a Total in XML

Trying to calculate a total Item weight. I have very little experience in xml and I thought this is what I would need.

<xsl:for-each select="//Order/Item" > 
    <xsl:variable name="tw" select='$tw + <xsl:value-of select = "/Weight"/>' />
</xsl:for-each>

but it is not valid.
or something like this

<xsl:for-each select="//Order/Item" > 
    <xsl:variable name="tw" select='$tw + /Weight' />
</xsl:for-each>
Avatar of suvmitra
suvmitra
Flag of India image

Why not use your data table (sql, access etc.) to do the calculation and then return the data set and write xml?
SOLUTION
Avatar of suvmitra
suvmitra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of frtools

ASKER

I gave gertone more points because the solution had a better explanation that led me to the right solution.