The Elements method returns just the child nodes of type XElement : XElement : XML LINQ C# Source Code


Custom Search

C# Source Code » XML LINQ » XElement »

 

The Elements method returns just the child nodes of type XElement








    
 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
public class MainClass {
    public static void Main() {
        var bench = new XElement("bench",
                      new XElement("A",
                        new XElement("B", "H"),
                        new XElement("B", "R")
                      ),
                      new XElement("A",
                        new XElement("B", "S"),
                        new XElement("C", "N")
                      ),
                      new XComment("comment")
                    );
        foreach (XElement e in bench.Elements())
            Console.WriteLine(e.Name + "=" + e.Value);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo XML LINQ
» XElement