C# lambda expressions in detail part 3
In our C# lambda expressions in detail part 3 post, we will see the lambda expressions being used with XML(exrtensible markup language).
Extensible Markup Language (XML) is a markup language that rely on some particular rules for making the file or a document easier to understand by both humans and machines.
This markup has the beauty to be accessible without any concern about the platform or the database which the computer machine is using.
LINQ to XML is better and easier than XSLT Transformations but wait
As people are used to transforming XML from one format to another, most of them rely on XSLT transformation.This method is very traditional but what if we have another technique for getting the task done?
A query language is very fruitful for extracting or manipulating the criteria based results . A transformation, would be useful to convert one XML representation of your data into another XML representation.
Now, lets see some working examples
<?xml version=”1.0″ encoding=”utf-8″ ?>
XDocument testXML = new XDocument();
var employees = from employee in testXML.Descendants(“Employee”)
ID = Convert.ToInt32(employee.Attribute(“ID”).Value),
Name = employee.Element(“Name”).Value
Lambda Expressions with Generic Collections
Generic Collections were introduced with C# 2.0. they provide a type safe mechanism to store and retrieve the data so the user can not input the data of mismatch types.
The common methods of traversing through these lists require a very large amount of programming code and doesn’t facilitate the art of programming aspect. In these sort of situations, the Lambda Expressions make the work very much easier to perform some logical operations when filtering our results.Here is my new post that clearly demonstrates how this can be achieved.