I get CompletedDate from XML document element name CompDate. This is an optional element. When the XML document has a CompDate element my VB.NET code works. However when the XML document does not have CompDate element, I get Object reference not set to an instance of an object?

How do I fix this so it works whether or not the CompDate element exist in the XML Document?

XML Document vb code is reading


Code:
<Integration>
   <Case>
     <CaseEvent ID="252949395">
	<CompDate>06/01/2019</CompDate>
     </CaseEvent>
   </Case>
   <IntegrationConditions>
      <IntegrationCondition>
	 <NotificationEvent elementKey="252949395">InsertPWBRorAOS</NotificationEvent>
      </IntegrationCondition>
   </IntegrationConditions>
</Integration>

What I have tried:

VB.NET code

Code:
Dim strEventId As String

strEventId = aobjxmlNotificationEventNode.SelectSingleNode("@elementKey").InnerText

objInsertPWBRorAOS.CompletedDate = CDate(aobjXmlInputDoc.DocumentElement.SelectSingleNode("Case/CaseEvent[@ID=" + strEventId + "]/CompDate").InnerText)