Get Descendants for a node : XElement « XML LINQ « C# / CSharp Tutorial






using System;
using System.Linq;
using System.Xml.Linq;

    class LinqToXml
    {
        static void Main(string[] args)
        {
            XElement doc = XElement.Load("table.xml");
            var products = from prodname in doc.Descendants("products") select prodname.Value;
            foreach (var prodname in products)
            Console.WriteLine("Product's Detail = {0}\t", prodname);
        }
    }








31.2.XElement
31.2.1.Parse Load xml from hard coded string
31.2.2.XML Fragments
31.2.3.Get Descendants for a node
31.2.4.Deal with White Spaces
31.2.5.Load xml from string, text file
31.2.6.Remove an element