Suppressing Node Construction with null : XElement : XML LINQ C# Source Code


Custom Search

C# Source Code » XML LINQ » XElement »

 

Suppressing Node Construction with null








    
 

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Linq;
public class MainClass {
    public static void Main() {
        IEnumerable<XElement> elements =new XElement[] {new XElement("Element", "A"),new XElement("Element", "B")};
        XElement xElement = new XElement("RootElement", elements.Select(e => (string)e != "A" ? new XElement(e.Name, (string)e) : null));
        Console.WriteLine(xElement);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo XML LINQ
» XElement