I am using SharePoint Web Services to get some list items out of SharePoint for a project i am working on.
I am using using LINQ to XML to parse the resulting XML to be put into a datasheet. The problem i am running into is when trying to parse an item that isn't required in SharePoint...
var fields = from item in results.Descendants(XName.Get("row", "#RowsetSchema"))
select new
{
ID = item.Attribute("ows_ID").Value,
Title = item.Attribute("ows_Title").Value,
DNS = item.Attribute("ows_DNS_x0020_Name").Value
};
DNS Name is not a required item in the list and some items do not have an entry for this. the resulting xml from sharepoint omits the field from the XML causing a "Object reference not set to an instance of an object." exception.
is there a workaround for this without me having to put a where clause in the LINQ statement (just because there isn't a DNS Name entered does not mean that i don't want it to show up in the results)