本文整理汇总了VB.NET中System.Windows.Forms.HtmlElement类的典型用法代码示例。如果您正苦于以下问题:VB.NET HtmlElement类的具体用法?VB.NET HtmlElement怎么用?VB.NET HtmlElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HtmlElement类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: PrintDomBegin
Private Sub PrintDomBegin()
If (WebBrowser1.Document IsNot Nothing) Then
Dim ElemColl As HtmlElementCollection
Dim Doc As HtmlDocument = WebBrowser1.Document
If (Not (Doc Is Nothing)) Then
ElemColl = Doc.GetElementsByTagName("HTML")
Dim Str As String = PrintDom(ElemColl, New System.Text.StringBuilder(), 0)
WebBrowser1.DocumentText = Str
End If
End If
End Sub
Private Function PrintDom(ByVal ElemColl As HtmlElementCollection, ByRef ReturnStr As System.Text.StringBuilder, ByVal Depth As Integer) As String
Dim Str As New System.Text.StringBuilder()
For Each Elem As HtmlElement In ElemColl
Dim ElemName As String
ElemName = Elem.GetAttribute("ID")
If (ElemName Is Nothing Or ElemName.Length = 0) Then
ElemName = Elem.GetAttribute("name")
If (ElemName Is Nothing Or ElemName.Length = 0) Then
ElemName = "<no name>"
End If
End If
Str.Append(CChar(" "), Depth * 4)
Str.Append(ElemName & ": " & Elem.TagName & "(Level " & Depth & ")")
ReturnStr.AppendLine(Str.ToString())
If (Elem.CanHaveChildren) Then
PrintDom(Elem.Children, ReturnStr, Depth + 1)
End If
Str.Remove(0, Str.Length)
Next
PrintDom = ReturnStr.ToString()
End Function