First, I want to admit I am totally new at Linq queries. Your help and patience are GREATLY appreciated!
I am trying to perform a query on a loaded XML document with the code below, but no matter what I try, I continually get an unhandled NullReferenceException error:
XDocument doc = XDocument.Load("tempdoc.xml"); IEnumerable<XElement> searched = from c in doc.Root.Elements("ContentErrs").Elements("TestID").Elements("Errors").Elements("Error") where (c.Element("Error").Name.Equals ("Error") || c.Element("Error").Name.Equals ("Warning")) select c;
I am fairly certain the problem revolves around the fact that not all of the Errors elements contain both Warning and Error elements both.
Can someone please provide advice?