I have a xml file.
<?xml version="1.0"?>
<RCATS xsi:noNamespaceSchemaLocation="/opt/radical/xml/schemas/RcatsExternalInterface.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<IDENTIFICATION-RECORD ACTION="ADD">
<ID>1200020100</ID>
<TRANSACTION-ID>3r7we43556564c6r34vl6z)zM6KF8i</TRANSACTION-ID>
<LAST-NAME>GEORGE</LAST-NAME>
<FIRST-NAME>BUSH</FIRST-NAME>
<MIDDLE-NAME>W</MIDDLE-NAME>
</IDENTIFICATION-RECORD>
</RCATS>
Then I have C# code to parse it.
XDocument doc = XDocument.Load(fileName);
var a = from x in doc.Descendants()
select x;
var d = from x in a
where x.Name.LocalName == "IDENTIFICATION-RECORD"
select x;
foreach (var i in d)
{
y = where x.Name.LocalName == "DISPOSITION"
select x).First().Value.ToLower() == "active" ? true : false;
The thing is sometimes there is no "DISPOSITION" element, in this case, I want
y = true; // if no "DISPOSITION" element found in file
Otherwise, keep the original code there if "DISPOSITION" is there.
How to check it?