I have page HTML stored in a variable... But I need to find a certain value in HTML
Let's say I have the HTML string:
HTML Code:
<html>
<head>
</head>
<body>
<table>
<tr>
<td>Money: </td>
<td>${VARIABLE1}</td>
<td>${VARIABLE2}</td>
<td>${VARIABLE3}</td>
<td>${VARIABLE4}</td>
</tr>
</table>
</body>
</html>
So I need to get from that string, a string that has:
"Variable1: {VARIABLE1}
Variable2: {VARIABLE2}
Variable3: {VARIABLE3}
Variable4: {VARIABLE4}"
Thanks,
Dan
Re: I have page HTML stored in a variable... But I need to find a certain value in HT
Not sure where your getting the text before the colon : from but if you want to get the text in between the <td> tags, which is the ${VARIABLE}s then check the link in my signature.
Re: I have page HTML stored in a variable... But I need to find a certain value in HT
You could also use regular expression, something like this :
VB.NET Code:
Dim sRegex As New Regex("<td>\$(\{.*\})</td>")
Dim matchCol As MatchCollection
If sRegex.IsMatch(RichTextBox1.Text) Then
matchCol = sRegex.Matches(HTMLString)
For Each m as Match in MatchCol
'Build your result here
'The value you are looking for is located in m.groups(1).ToString()
Next
End If
Have a look at the first link in my signature to have a better idea of the Regular Expressions syntax.
Hope this helps.
Re: I have page HTML stored in a variable... But I need to find a certain value in HT
I got it figured out last night actually... My code was all 100% working, but I had the WebClient set to a 5 second timeout, so it would work some of the time but not all the time... It was so confusing because I thought what I was changing was causing the errors, but it was just the variable load time of the web page, so my VisualBasic code was right all along.
Here's what I used:
VisualBasic Code:
Dim Labels() As String = {"Raised", "Spent", "Cash on Hand", "Debts"}
PageHtml = GetHTML(CurrentIDURL)
Split1 = Split(PageHtml, "$", -1)
For x = 1 To 4
y = x - 1
Split2 = Split(Split1(x), "</td>", -1)
FullTextFileString += Labels(y) + "~$" + Split2(0) + vbCrLf
Next
And then the full file is inside "FullTextFileString"
Thanks for all of your help though!