5 Replies - 666 Views - Last Post: 11 August 2012 - 09:52 AM Rate Topic: -----

#1 camrymps  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 10-August 12

Obtaining the value between two tags

Posted 10 August 2012 - 11:53 AM

Hi everyone! I am trying to get the value between the two tags below and put that value into a textbox.

<strong>142</strong>

Is This A Good Question/Topic? 0
  • +

Replies To: Obtaining the value between two tags

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9573
  • View blog
  • Posts: 36,255
  • Joined: 12-June 08

Re: Obtaining the value between two tags

Posted 10 August 2012 - 11:59 AM

Use regex.

It occurred to me that while you might not have furnished any of the bits that make it easier for us to help you - like what you have tried, your code so far, etc - that I could go a bit above and beyond and give you some links..

http://www.dreaminco...g-a-web-spider/
http://msdn.microsof...y/az24scfc.aspx
Was This Post Helpful? 0
  • +
  • -

#3 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,499
  • Joined: 29-May 08

Re: Obtaining the value between two tags

Posted 10 August 2012 - 12:32 PM

If it is XML or XHTML, then use an XML approach.
Dim theTag = <strong>142</strong>
Console.WriteLine( theTag.Value )


Was This Post Helpful? 0
  • +
  • -

#4 camrymps  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 10-August 12

Re: Obtaining the value between two tags

Posted 11 August 2012 - 07:12 AM

View PostAdamSpeight2008, on 10 August 2012 - 12:32 PM, said:

If it is XML or XHTML, then use an XML approach.
Dim theTag = <strong>142</strong>
Console.WriteLine( theTag.Value )



I know how to do this but what I have been trying to do is find the two strong tags in an html document and then take out the number, because the number will not always be 142. I have tried parsing the html and inserting an id in to the strong tag, that didnt work. I have no idea in the world how to use regex. So im just plain stuck.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9573
  • View blog
  • Posts: 36,255
  • Joined: 12-June 08

Re: Obtaining the value between two tags

Posted 11 August 2012 - 08:41 AM

You are not stuck - you need to read up on regex and implement it. It's not that bad.
Was This Post Helpful? 0
  • +
  • -

#6 camrymps  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 10-August 12

Re: Obtaining the value between two tags

Posted 11 August 2012 - 09:52 AM

Ok I am trying a different approach. I set the page to text only and now the html is as follows:

<a href="/camrymps/followers/" class="selected">
      142
    </a>


I used this code to try to get the number 142, but it didnt work:

Dim allelements As HtmlElementCollection = WebBrowser1.document.All

        For Each webpageelement As HtmlElement In allelements

            If webpageelement.GetAttribute("class") = "selected" Then

                TextBox2.AppendText(webpageelement.ToString)

            End If

        Next

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1