|
-
Aug 17th, 2009, 09:12 PM
#1
Thread Starter
New Member
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
-
Aug 17th, 2009, 10:25 PM
#2
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.
-
Aug 18th, 2009, 06:56 AM
#3
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.
Alex
.NET developer
"No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)
Things to consider before posting.
Don't forget to rate the posts if they helped and mark thread as resolved when they are.
.Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
My fresh new blog : writingthecode, even if I don't post much.
System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0 
-
Aug 18th, 2009, 10:25 AM
#4
Thread Starter
New Member
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|