if exists XML Element

Mar 5 2021 9:46 PM
from the below code
How do i find, if there EXISTS an xmlElemenent MiddleName(i am not asking for value) before i evaluate it
something like if exists(MiddleName)  then.....
Sometimes in my xml the attribute(not the value) might not exists 
 
 
public static string ProcessXMLdata(XElement xml)
{
try
{
string processResult;
XNamespace ns = "http://schemas.datacontract.org/2004/07/BondData.Shared.DataModels.Peoplehouse";
if (xml.Element(ns + "FirstName").Value == null ||
xml.Element(ns + "LastName").Value == null ||
xml.Element(ns + "MiddleName").Value == null ||
xml.Element(ns + "ApplicantAddress").Value == null ||

Answers (1)