Call GetElementsByTagName to get an element : XmlDocument : XML C# Source Code


Custom Search

C# Source Code » XML » XmlDocument »

 

Call GetElementsByTagName to get an element








    
 

using System;
using System.Xml;

public class MainClass {
    private static void Main() {
        XmlDocument doc = new XmlDocument();
        doc.Load("ProductCatalog.xml");

        XmlNodeList prices = doc.GetElementsByTagName("productPrice");

        decimal totalPrice = 0;
        foreach (XmlNode price in prices) {
            totalPrice += Decimal.Parse(price.ChildNodes[0].Value);
        }

        Console.WriteLine("Total catalog value: " + totalPrice.ToString());
    }

}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo XML
» XmlDocument