本文整理匯總了VB.NET中System.Windows.Forms.HtmlElement.Children屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET HtmlElement.Children屬性的具體用法?VB.NET HtmlElement.Children怎麽用?VB.NET HtmlElement.Children使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Windows.Forms.HtmlElement
的用法示例。
在下文中一共展示了HtmlElement.Children屬性的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