|
-
Nov 29th, 2012, 10:39 PM
#1
Thread Starter
New Member
How to parse certain text in the webbrowser?
What I'm trying to do is parse certain text from a webpage that is loaded into the webbrowser. To be more specific, this line of code.
Code:
<span class="price" id="selecttrainform1_addToCartPrice">$20.00</span>
It sits on line 1342. If it helps, this is all the code before it, that sits on the same line.
Code:
<nobr><input type="image" onclick="return onAddToCartClick('selecttrainform', '1', '');" src="/images/en/avs_addtocart_gray.gif" alt="Add To cart >" border="0" name="_handler=presentation.handler.request.rail.RailSimpleSelectDepartAvailabilityRequestHandler/_xpath=/sessionWorkflow/productWorkflow[@product='Rail']/tripJourneyTariffAvailability/journeyTariffAvailability[1]/binding[1]/journey/segment[1]/_/sessionWorkflow/productWorkflow[@product='Rail']/selectedJourney/@id_=_hy0s6wf8a3gi" /><span class="price" id="selecttrainform1_addToCartPrice">$20.00</span>
What I'm trying to do with that price is have a message box display it. I can either have three different msgbox come up, drawing from three different webbrowsers, or just one msgbox that shows from all three. It's not a big deal to me. As well, this code will just be placed in a button. Of course, if need be, I can have the information display in a textbox rather than a msgbox. I just much prefer a msgbox.
I was thinking I could use something like
Code:
If webpageelement3.GetAttribute("id") = "selecttrainform1_addToCartPrice" Then
MsgBox("the price data here")
but I'm not sure how that'd work to get it to display into the messagebox. The above code is part of what I used to find and click a button, just left out the webpagelement.invokemember("click") command.
Does anyone know of any resources or links that would be helpful? I've tried searching through google but it's been fruitless for the moment.
I've already tried many of the posts on this forum but none of them seem to help.
-
Nov 30th, 2012, 12:53 PM
#2
Re: How to parse certain text in the webbrowser?
Dim price As String = WebBrowser1.Document.GetElementById("selecttrainform1_addToCartPrice").InnerText
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
Tags for this Thread
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
|