XElement.IsEmpty gets a value indicating whether this element contains no content.
using System;
using System.Linq;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass{
public static void Main(){
XElement el1 = new XElement("Root");
Console.WriteLine(el1);
Console.WriteLine(el1.IsEmpty);
Console.WriteLine();
XElement el2 = new XElement("Root", "content");
Console.WriteLine(el2);
Console.WriteLine(el2.IsEmpty);
Console.WriteLine();
XElement el3 = new XElement("Root", "");
Console.WriteLine(el3);
Console.WriteLine(el3.IsEmpty);
Console.WriteLine();
el3.ReplaceAll(null);
Console.WriteLine(el3);
Console.WriteLine(el3.IsEmpty);
}
}
Related examples in the same category