Below is the sample XML file code.
<?xml version="1.0" encoding="utf-8"?>
<Employees>
<Employee Id="2" Name="Ram" />
<Employee Id="5" Name="Rahul" />
<Employee Id="8" Name="Manimaran" />
<Employee Id="9" name="John" />
</Employees> And now the code to get max value.XElement element = XElement.Load("../../Employees.xml");
int max =
element.Elements("Employee").Max(l => int.Parse(l.Attribute("Id").Value));