Create an XElement class from an XStreamingElement object.
using System;
using System.Linq;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass{
public static void Main(){
XElement src = new XElement("Root",
new XElement("Child1", 1),
new XElement("Child2", 2),
new XElement("Child3", 3)
);
XStreamingElement xse = new XStreamingElement("NewRoot",
from el in src.Elements()
where (int)el >= 2
select el
);
Console.WriteLine(xse);
src.Add(new XElement("Child4", 4));
Console.WriteLine(xse);
}
}
Related examples in the same category