Question finding string within HTML tags

rpg711

Member
Joined
Dec 23, 2008
Messages
5
Programming Experience
1-3
Ok, so I need to find a string within html tags, and then have that string be either directly transfered to textbox, or read to a var and then to a textbox.
VB.NET:
 <span class="field-prefix">3 + 0 = </span>

How would I read the 3 + 0 = out of the tags?
 
Hopefully someone will show you a better way but this should work
VB.NET:
        Dim Reader As System.IO.StreamReader = New IO.StreamReader("path\file.html")
        Dim stringReader As String = Reader.ReadLine()
        While Reader.ReadLine IsNot Nothing
            stringReader = Reader.ReadLine()
            If stringReader.Contains("field-prefix") Then
                Dim split1 As String() = stringReader.Split(New [Char]() {"<", ">"})
                TextBox1.Text = split1(2)
            End If
        End While
        Reader.Close()
 
You can also load it into a WebBrowser and use Document tree to get the element text:
VB.NET:
Dim s As String = Me.WebBrowser1.Document.GetElementsByTagName("span")(0).InnerText
 
thanks for the help, but I already figured it out.
I used
VB.NET:
innhtml = webb.Document.Body.InnerHtml
            innhtml = innhtml.IndexOf("field-prefix")
            substing = webb.Document.Body.InnerHtml.Substring(startIndex:=innhtml + 13, length:=2)
            num1 = substing
thanks anyways
 
Back
Top