vb.net 教程 12-4 msHtml 3

vb.net 教程 12-4 msHtml 3,第1张

概述相比之前学习的HtmlDocument类和HtmlElement类,mshtml还提供了网页元素更详细的分类,比如 IHTMLScriptElement :脚本元素 IHTMLStyleSheet :样式表 IHTMLFormElement:表单元素 等等 这些不同的元素分类有着自己的特殊属性和方法。 获得脚本信息: Private Sub Button3_Click(sender As 相比之前学习的HTMLdocument类和HTMLElement类,msHTML还提供了网页元素更详细的分类,比如 IHTMLScriptElement :脚本元素 IHTMLStyleSheet :样式表 IHTMLFormElement:表单元素 等等 这些不同的元素分类有着自己的特殊属性和方法。
获得脚本信息:
    Private Sub button3_Click(sender As Object,e As EventArgs) Handles button3.Click        Dim doc As msHTML.IHTMLdocument        doc = wbMain.document.Domdocument        Dim scrs As msHTML.IHTMLElementCollection = doc.scripts        Dim scr As msHTML.IHTMLScriptElement        For i As Integer = 0 To scrs.length - 1            scr = CType(scrs.item(i),msHTML.IHTMLScriptElement)            txtInfo.Text &= "HTMLFor:" & scr.HTMLFor & vbCrLf            txtInfo.Text &= "event:" & scr.event & vbCrLf            txtInfo.Text &= "src:" & scr.src & vbCrLf            txtInfo.Text &= "text:" & scr.text & vbCrLf            txtInfo.Text &= "type:" & scr.type & vbCrLf            txtInfo.Text &= "====================" & vbCrLf        Next    End Sub
运行如下: 获得样式表信息:
    Private Sub button4_Click(sender As Object,e As EventArgs) Handles button4.Click        Dim doc As msHTML.IHTMLdocument2        doc = wbMain.document.Domdocument        Dim styles As msHTML.HTMLStyleSheetsCollection = doc.styleSheets        Dim style As msHTML.IHTMLStyleSheet        For i As Integer = 0 To styles.length - 1            style = CType(styles.item(i),msHTML.IHTMLStyleSheet)            txtInfo.Text &= "csstext:" & style.csstext & vbCrLf            txtInfo.Text &= "href:" & style.href & vbCrLf            txtInfo.Text &= "ID:" & style.ID & vbCrLf            txtInfo.Text &= "Title:" & style.Title & vbCrLf            txtInfo.Text &= "type:" & style.type & vbCrLf            txtInfo.Text &= "====================" & vbCrLf        Next    End Sub
运行如下: 获得表单信息:
    Private Sub button5_Click(sender As Object,e As EventArgs) Handles button5.Click        Dim doc As msHTML.HTMLdocument        doc = wbMain.document.Domdocument        doc.sc        Dim eles As msHTML.IHTMLElementCollection = doc.forms        Dim frm As msHTML.IHTMLFormElement        For i As Integer = 0 To eles.length - 1            frm = CType(eles.item(i),msHTML.IHTMLFormElement)            txtInfo.Text &= "action:" & frm.action & vbCrLf            txtInfo.Text &= "enCoding:" & frm.enCoding & vbCrLf            txtInfo.Text &= "method:" & frm.method & vbCrLf            txtInfo.Text &= "name:" & frm.name & vbCrLf            txtInfo.Text &= "target:" & frm.target & vbCrLf            txtInfo.Text &= "====================" & vbCrLf        Next    End Sub
运行如下:

由于.net平台下C#和vb.NET很相似,本文也可以为C#爱好者提供参考。

学习更多vb.net知识,请参看 vb.net 教程 目录

总结

以上是内存溢出为你收集整理的vb.net 教程 12-4 msHtml 3全部内容,希望文章能够帮你解决vb.net 教程 12-4 msHtml 3所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1279169.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存