I am checking a HtmlDocument() by html id called shippingMessage_ftinfo_olp_1
but problem is that i am unable to check if this is a null exception. Because when i set if !=null
still it throws exception. Anyone can tell me how can i check it if its null without this exception?
System.NullReferenceException: 'Object reference not set to an instance of an object.'
HtmlDocument htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(response);
string gerLang = "";
if (htmlDoc.GetElementbyId("shippingMessage_ftinfo_olp_1").InnerText != null)
{
gerLang = htmlDoc.GetElementbyId("shippingMessage_ftinfo_olp_1").InnerText;
if(gerLang.Contains("AmazonGlobal Express-Zustellung"))
{
_outOfStock = false;
}
}