本文整理汇总了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
开发者ID:VB.NET开发者,项目名称:System.Windows.Forms,代码行数:41,代码来源:HtmlElement
注:本文中的System.Windows.Forms.HtmlElement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论