hi. i have the following xml
<students>
<student>
<id>12</id>
<name>Mohsan</name>
</student>
<student>
<id>2</id>
</student>
<student>
<id>3</id>
<name>Azhar</name>
</student>
</students>
note that in 2 name element is missing.
i have to read this xml using Linq to XML
i used following code to get all students..
please suggest me improvement in this code
var stds = from std in doc.Descendants("student")
select new
{
ID = std.Element("id").Value,
Name = (std.Element("name")!=null)?std.Element("name").Value:string.Empty
};