XElement.HasElements gets a value indicating whether this element has at least one child element.
using System;
using System.Linq;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass{
public static void Main(){
XElement xmlTree1 = new XElement("Root",
new XElement("Child", 1)
);
Console.WriteLine(xmlTree1.HasElements);
XElement xmlTree2 = new XElement("Root", "contents");
Console.WriteLine(xmlTree2.HasElements);
}
}
Related examples in the same category