Why Descendants() and DescendantsAndSelf() returning same result?
using System;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using System.Collections.Generic;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
XElement ele = XElement.Load("Employees.xml");
//IEnumerable<XElement> elements = ele.Descendants("City");
IEnumerable<XElement> elements = ele.DescendantsAndSelf("City");
foreach(var item in elements)
Console.WriteLine(item);
}
}
}
//Output
/*
<City>Acampo</City>
<City>Alta</City>
<City>Milford</City>
<City>Montara</City>
Press any key to continue . . .
*/
Member
68 Points
240 Posts
Descendants() and DescendantsAndSelf()
Feb 13, 2019 05:07 AM|vinodkpasi|LINK
Why Descendants() and DescendantsAndSelf() returning same result?
Employees.xml