StealthRT
StealthRT

Reputation: 10542

Checking for XML NODE null

Is there anyway to check for a null here before it reaches this part of the code?

tmpLabelData(0) = m_node.Item("CONTAINER_NAME").InnerText

Some XML has it while others do not. I cant seem to find a nice way to handle a null on these?

David

Upvotes: 2

Views: 5320

Answers (1)

NoAlias
NoAlias

Reputation: 9193

If Not m_node.Item("CONTAINER_NAME") Is Nothing AndAlso _
       Len(m_node.Item("CONTAINER_NAME").InnerText) > 0 Then

   tmpLabelData(0) = m_node.Item("CONTAINER_NAME").InnerText 

End If 

Upvotes: 3

Related Questions