XML linq query lists first elements but not all?

That looks like one (or more) of kobra. Descendants has ows_ID ows_Title or ows_Source_x0020_Message_x0020_File attribute missing Linq uses deferred execution so it won't try to build the sequence until you ask for the items. When you call Any() or First(), it only needs the first item in the sequence to work, which tells me that the first item in kobra.

Descendants does have all of the required nodes However, one of the items after the first is probably missing at least one of those attributes - so you end up asking for the Value of a NULL attribute.

That looks like one (or more) of kobra. Descendants has ows_ID, ows_Title or ows_Source_x0020_Message_x0020_File_ attribute missing. Linq uses deferred execution, so it won't try to build the sequence until you ask for the items.

When you call Any() or First(), it only needs the first item in the sequence to work, which tells me that the first item in kobra. Descendants does have all of the required nodes. However, one of the items after the first is probably missing at least one of those attributes - so you end up asking for the Value of a NULL attribute.

Inside select new Module { // properties... } You could be running into a NullReferenceException as you access . Value on elements that might not exist in the XML document. Your first object in the collection is likely fine, hence your results when using Any() or First().

Subsequent items could be missing elements/attributes you are trying to use. Try this as a replacement instead of using . Value directly.Id = (string)s.

Attribute("whatever") // etc.

Holy sh** you're right, I was 100% sure the XML file was complete with all attributes and couldn't be the cause. Thx! – Antoine Jun 29 at 15:43.

One of your lines such as s. Attribute("ows_Source_x0020_Message_x0020_File_") will be returning null for one of the records so s. Attribute("ows_Source_x0020_Message_x0020_File_").

Value would cause the null reference exception.

Linq uses deferred execution, so it won't try to build the sequence until you ask for the items. When you call Any() or First(), it only needs the first item in the sequence to work, which tells me that the first item in kobra. Descendants does have all of the required nodes.

However, one of the items after the first is probably missing at least one of those attributes - so you end up asking for the Value of a NULL attribute.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions