VB.NET GetElementById 内文 [英] VB.NET GetElementById innertext
问题描述
好的,这是我带有 ID 的 html 行:
<id="accounttype" class=inline-block"><strong><?=$_SESSION['accounttype']?></strong><br>
这就是它抓取的东西
当然虽然这变成了文字
<?=$_SESSION['accounttype']?>
这是我的 vb.net 代码
TextBox4.Text = WebBrowser1.Document.GetElementById("accounttype").InnerText
当我运行程序时出现此错误
未将对象引用设置为对象的实例.
我没有看到 ID 为 accounttype
的元素.我所看到的只是一个 ID 为 newssite
的元素.GetElementById
返回属性 id
等于您传递它的任何元素的元素.例如:
Hello World
和 VB.NET 代码:
TextBox4.Text = WebBrowser1.Document.GetElementById("accounttype").InnerText
您可能没有包含代码;但在尝试使用它之前,您还应该确保 WebBrowser 已完全加载其内容.
Okay so this is my html line with the ID:
<id="accounttype" class=inline-block"><strong><?=$_SESSION['accounttype']?></strong><br>
this is what it grabs
of course though that turns into text
<?=$_SESSION['accounttype']?>
this is my vb.net code
TextBox4.Text = WebBrowser1.Document.GetElementById("accounttype").InnerText
When i run the program i get this error
Object reference not set to an instance of an object.
I don't see an element with an ID of accounttype
. All I see is an element with an ID of newssite
. GetElementById
returns the element who has an attribute id
equal to whatever you pass it. For example:
<div id="accounttype">Hello World</div>
And the VB.NET Code:
TextBox4.Text = WebBrowser1.Document.GetElementById("accounttype").InnerText
You may not have included the code; but you should also make sure the WebBrowser has completely loaded its contents before trying to work with it.
这篇关于VB.NET GetElementById 内文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!