<?xml version="1.0" encoding="utf-8"?>
<Customers>
<Customer Id="1">
<Name>rtertr</Name>
<DOB>2010-12-12T00:00:00</DOB>
<EMail>werer@test.com</EMail>
</Customer>
<Customer Id="2">
<Name>west</Name>
<DOB>0001-01-01T00:00:00</DOB>
<EMail>west@test.com</EMail>
</Customer>
<Customer Id="3">
<Name>west</Name>
<DOB>0001-01-01T00:00:00</DOB>
<EMail>west@test.com</EMail>
</Customer>
</Customers>
How to find Min and Max CustomerId from the above sample XML using LinQ to XML? For example for the above sample, Min should be 1 and Max should be 3
You can use the Min and Max extension methods:
or the Aggregate extension method (iterating the XML document only once):