'How do I output html <span> text without id?
I'm trying to make a program that will be able to output definitions and syllables for words. So far I've got this code:
Imports System.Text.RegularExpressions
Public Class Form3
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
Label1.Text = ""
WebBrowser1.Navigate("http://www.thefreedictionary.com/")
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
Button1.Enabled = True
Button2.Enabled = True
End Sub
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("http://www.thefreedictionary.com/")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Document.GetElementById("f1word").SetAttribute("value", TextBox1.Text)
Dim allelements As HtmlElementCollection = WebBrowser1.Document.All
For Each webpageelement As HtmlElement In allelements
If webpageelement.GetAttribute("value") = "Search" Then
webpageelement.InvokeMember("Click")
End If
Next
End Sub
End Class
And now I want to be able to output the element that is holding the syllables and definition into a label. How do I do that?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
