Sunday 12 August 2012

get all html element in vb.net

In this tutorial, we cover how to interact with every single HTML Element in a web page. First navigate your page and as usual using built in web browser in application First line get all html element collection to get that we use web browser document all For each element we listed in list box and use for further To make this application all you need 1 web browser 1 Text box 1 List box 1 button Copy and paste below Code:
Public Class Form1
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 WebBrowser1.Navigate("www.youtube.com")
 End Sub
 Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
 Dim allelements As HtmlElementCollection = WebBrowser1.Document.All
 For Each webpageelement As HtmlElement In allelements
 ListBox1.Items.Add(webpageelement.GetAttribute("src"))
 Next
 End Sub 
End Class