Using Web Browser in Windows Forms

  • Thread starter Thread starter jokolee
  • Start date Start date
J

jokolee

I'm using web browser to view web page in vb form......I wanna read
how much <div> is in the page ( it should be 3), but can't work
it.....In javascript it's gonna be something like this.......
(browser-object.contentDocument.documentElement.childNodes.item(1).childNodes).....I
already using the ihtmldocument, but not working out...

Example html page :

<body>
<div id="1">
------
</div>
<div id="2">
------
</div>
<div id="3">
------
</div>
</body>

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
I thought you could do something as simple as
browser.document.all.tags("DIV").length, but it's not working. The
following function does it, but if the document is large, it can take a
while:

Public Function GetTagCount(ByVal browser As AxSHDocVw.AxWebBrowser,
ByVal tag As String)
Dim count As Integer = 0
For Each o As Object In browser.Document.all
If UCase(o.tagname) = UCase(tag) Then
count += 1
End If
Next
Return count
End Function

Scott Swigart
blog - http://ea.3leaf.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top