EDN Admin
Well-known member
Hi,
I am new in writing Xpath in C# and i am not able to get Sum of Quantity from xml data. i.e i want to get total quantity from multiple lines elements as in one unit of data.
The following xml shows some sample xml data :
<lines><br/>
<line><br/>
<line_no>11</line_no><br/>
<qty>50</qty><br/>
</line><br/>
<line><br/>
<line_no>12</line_no><br/>
<qty>150</qty><br/>
</line><br/>
<line><br/>
<line_no>13</line_no><br/>
<qty>100</qty><br/>
</line><br/>
<line><br/>
<line_no>14</line_no><br/>
<qty>90</qty><br/>
</line><br/>
<line><br/>
<line_no>15</line_no><br/>
<qty>40</qty><br/>
</line><br/>
</lines>
for the above code i have written Xpath like:
int total=SelectSingleNode("/lines/line/qty").Value;
By this i am getting only first line element quantity but i need to get all lines quantity i think here i need to Loop the lines of data if yes please help me how to write the xpath query.
Thanks,
Raghu.
<br/>
View the full article
I am new in writing Xpath in C# and i am not able to get Sum of Quantity from xml data. i.e i want to get total quantity from multiple lines elements as in one unit of data.
The following xml shows some sample xml data :
<lines><br/>
<line><br/>
<line_no>11</line_no><br/>
<qty>50</qty><br/>
</line><br/>
<line><br/>
<line_no>12</line_no><br/>
<qty>150</qty><br/>
</line><br/>
<line><br/>
<line_no>13</line_no><br/>
<qty>100</qty><br/>
</line><br/>
<line><br/>
<line_no>14</line_no><br/>
<qty>90</qty><br/>
</line><br/>
<line><br/>
<line_no>15</line_no><br/>
<qty>40</qty><br/>
</line><br/>
</lines>
for the above code i have written Xpath like:
int total=SelectSingleNode("/lines/line/qty").Value;
By this i am getting only first line element quantity but i need to get all lines quantity i think here i need to Loop the lines of data if yes please help me how to write the xpath query.
Thanks,
Raghu.
<br/>
View the full article