检查HTML元素的文档存在于WebBrowser控件(vb.net) [英] check if HTMLElement exists in Document in webbrowser control (vb.net)
本文介绍了检查HTML元素的文档存在于WebBrowser控件(vb.net)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获得它有一个ID为块HTML元素一个内部的HTML。
我曾尝试:
I am trying to get the HTML inside a HTMLElement which has an id "block". I have tried:
If webbrowser1.document.getelementbyid("block") isnot nothing then
MsgBox(webbrowser1.document.getelementbyid("block").innerHTML)
end if
但它保持扔一个NullReferenceException,并告诉我要检查,如果这是我在做什么是空/罢了。
But it keep throwing a NullReferenceException and tells me to check if it null/nothing which is what I'm doing.
那么,如何检查是否在HTMLDocument中具有一定的ID的元素存在?
So how do I check if an element in a HTMLdocument with a certain ID exists?
推荐答案
什么是有可能发生在这里是webbrowser1.document什么,这是什么导致了的NullReferenceException
是抛出。
What's likely happening here is that webbrowser1.document is Nothing and that is what's causing the NullReferenceException
to be thrown.
请尝试以下code
If webbrowser1.document IsNot Nothing Then
Dim element = webbrowser1.document.getelementbyid("block")
if element isNot Nothing Then
MsgBox(element.innerHTML)
End if
end if
这篇关于检查HTML元素的文档存在于WebBrowser控件(vb.net)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文