Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Sum function in an XPath expression using ASP

From: "Atif Sarfraz" <atifsarfraz@-------.--->
To: NULL
Date: 8/7/2004 4:54:00 PM
This is a multi-part message in MIME format.

------=_NextPart_000_0016_01C47C9F.1EA5C080
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

I am trying to do a sum of amounts node using the following XPath =
expression sum(//Charges/Charge/Amount). The XPath expression works fine =
when I run it on my XML, using an XSL. However I want to use the same =
expression through a DOMDocument as follows.=20

<%
dim TotalCharge, MyXML

' Suppose that I have my xml loaded in a DOMDocument called MyXML. So I =
am trying to do a sum of all Charges.
TotalCharge =3D MyXML.selectSingleNode("sum(//Charges/Charge/Amount)")

%>

The above call fails because it expects a node from the XPath =
expression, however the value returned is a Number.=20
Is there some way of making this work?

Regards,

Atif Sarfraz
------=_NextPart_000_0016_01C47C9F.1EA5C080
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.3790.186" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I am trying to do a sum of amounts node =
using the=20
following XPath expression <FONT=20
color=3D#0000ff>sum(//Charges/Charge/Amount)</FONT>. The XPath =
expression works=20
fine when I run it on my XML, using an XSL. However I want to use the =
same=20
expression through a DOMDocument as follows. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&lt;%</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>dim TotalCharge, =
MyXML</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>' Suppose that I have =
my xml loaded=20
in a DOMDocument called MyXML. So I am trying to do a sum of all=20
Charges.</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>TotalCharge =3D=20
MyXML.selectSingleNode("sum(//Charges/Charge/Amount)")</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>%&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>The above call fails because it expects =
a node from=20
the XPath expression, however the value returned is a Number. =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Is there some way of making this =
work?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Regards,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Atif Sarfraz</FONT></DIV></BODY></HTML>

------=_NextPart_000_0016_01C47C9F.1EA5C080--



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent