Q: How to set a default value for attribute if it doesn't exist in the XDocument object I am trying to load an xml file.
I did this:
from e in XDocument.Load(stream).Root.Elements("cust")
                            select new Customer
                            {
                                MemeberID = (int)e.Attribute("custid"),
                                CustomerID = (int)e.Attribute("custid"),
                                FirstName = (string)e.Attribute("fname"),
                                LastName = (string)e.Attribute("lname"),
                                ShowsNumber = (int)e.Attribute("count_noshow"),
                                VisitNumber = (int)e.Attribute("count_resos"),
                                Cancellation = (int)e.Attribute("count_cancel"),
                                MobileNumber = (string)e.Element("phone").Attribute("phonenumber")
                            })

even thing was working good, but now i have a situation in which the xml document is not neccessary to have the mobilenuber attribute. 
so can I set a default value for this mobile number if it wasn't there in the xml node?
many thanks

A: Attribute not required:
MobileNumber = (string)e.Element("phone").Attribute("phonenumber") ?? defaultValue

Element not required:
MobileNumber = e.Element("phone") != null ? (string)e.Element("phone").Attribute("phonenumber") : defaultValue

