According to documentation, if element does not exists, then xml.Element(ns + "MiddleName") will be null. Therefore, you can use a condition like ‘xml.Element(ns + "MiddleName") == null’.
If you want to check if the element does not exists or the value is null or empty, try
xml.Element(ns + "MiddleName")?.Value == null
or
string.IsNullOrWhitespace(xml.Element(ns + "MiddleName")?.Value)