I have this LINQ to XML enquiry...
var Records = from Item in XDoc.Root.Elements("Item")
where (string)Item.Element("ItemNumber") == item.ID.ToString
select Item;
... where ItemNumber is a reference number used in the XML, (originally written by this program but manually edited by "others"), and item.ID is the database version of the same thing. The query executes, and I can test for the number of entries in the result fine...
if (Records.Count() < 1)
... you get the idea. I have established that there is only one record, (the editor has not removed or duplicated/multiplid the item).
Each Item has several child fields. I want to test the values of the child fields are reasonable before passing them on to the database update sub-system. The XML is produced by the program, but edited by users, so I need to really check what is coming back. So I tried...
if (DB_English.ToString() != Records.Elements("English").ToString())
... DB_English is from the database, but the XML in Records, does not contain the contents of that field, it contains...
System.Xml.Linq.Extensions+<GetElements>d__29`1[System.Xml.Linq.XElement]
... so, how do I get the value of this element in the XML file? I need to check the field in the XML has not been altered, (the manual editors of this data file are not potentially 100% reliable).