CSharp examples for System.Xml:XML Node
Gets the sum of the double values for all nodes returned by executing the supplied XPath query on the supplied Node
using System.Xml.Xsl; using System.Xml; using System.Text.RegularExpressions; using System.Text; using System;/*from w ww . j a v a 2 s. c o m*/ public class Main{ #endregion #region GetNodeSum(); GetNodeText(); /// <summary> /// Gets the sum of the double values for all nodes returned by executing the supplied XPath query on the supplied Node /// </summary> /// <param name="XPath">The string XPath to the nodes containing numeric values to be added</param> /// <param name="Node">The XmlNode to be selected from</param> /// <returns>The double value containing the sum of all double values in the nodes returned by the XPath query</returns> public static double GetNodeSum(string XPath, XmlNode Node) { double dOutput = 0; foreach(XmlNode oChildNode in Node.SelectNodes(XPath)) { dOutput += Parser.ToDouble(oChildNode.InnerText); } return dOutput; } }