I’m building a software to process orders on a site. I’m using DOM to navigate through the website and I want my app not to hang when I use a command on the “wrong” page.
Ex:
try
WebBrowser.OleObject.Document.GetElementByID('ContentPlaceHolder1_txtCommande').setAttribute('value', lblDate.Caption);
except
end;
All I want is for the error to be ignored if the field is not found as this error is not important. Thank you!
Edit: wrote ADO when I meant DOM
You yourself say that the element might not be found, so what do you expect
to return other than
nilin that case? Yet you “blatantly” use whatever is returned by appendingto it.
Change your code to
Edit
if you are working with variants instead of using msxml through its type library or some other xml library in which you can find the proper type returned by GetElementID, then, as @GerryColl mentions, you can use
element: OLEVariantand check for NULL instead of for a nil pointer.