A Simple LINQ to XML Program That Parses a Small XML File and Finds Customers Who Live in Mexico D.F.
using System;
using System.Linq;
using System.Xml.Linq;
namespace SimpleXmlExample
{
class Program
{
public static void main(string[] args)
{
XDocument customers = new XDocument("Customers.xml");
var query = from e in customers.Descendants("Customer") where e.Attribute("City").Value == "Mexico D.F." select e;
foreach (var customer in query)
{
Console.WriteLine(customer);
}
}
}
}