Vb.net innerhtml和outerhtml之间的差异
我面临着一个只有偶尔才会发生的错误:Vb.net innerhtml和outerhtml之间的差异,vb.net,innerhtml,outerhtml,Vb.net,Innerhtml,Outerhtml,我面临着一个只有偶尔才会发生的错误: 我试图检查一个表(进入网页)是否包含另一个表,为此,我在和中查找标记html代码。 有时,从包含主表的对象中提取innerhtml时出错(就像它没有innerhtml)。 所以我尝试了下面的代码,似乎问题已经解决了 Try If mTables(1).innerhtml.contains("<table>") _ AndAlso mTables(1).innerhtml.contains("</table>")
我试图检查一个表(进入网页)是否包含另一个表,为此,我在
和
中查找标记html
代码。有时,从包含主表的对象中提取innerhtml时出错(就像它没有
innerhtml
)。所以我尝试了下面的代码,似乎问题已经解决了
Try
If mTables(1).innerhtml.contains("<table>") _
AndAlso mTables(1).innerhtml.contains("</table>") Then
'some code
Else
'some code
End If
Catch ex As Exception
Try
If mTables(1).outerhtml.contains("<table>") _
AndAlso mTables(1).outerhtml.contains("</table>") Then
'some code
Else
'some code
End If
Catch ex2 As Exception
'some code
End Try
End Try
但是如果有人能给我解释一下
innerHtml
和outerHtml
之间的区别,我将不胜感激。有一个简单的例子表明了他们之间的区别:。。。我不确定,但我认为只有IE才支持innerText
,相当于FF,chrome是textContent
。。。有一个小提琴示例显示了innerHTML
和textContent
(您的问题3)之间的差异:不确定,但尝试只使用catch
(outerhtml
)下的代码。@nelek感谢链接(我学到了一些其他东西,但在这种情况下似乎对我没有帮助)。我试图只使用outerhtml
,但有时我会出错:我发现的唯一方法是在我的问题中,但我不确定,因为我真的不了解我在做什么。。。
If mTables(1).getelementsbytagname("table").length > 0 then
...