How would you grab this element by "P"??

Discussion in 'Visual Basic .NET' started by simpleonline1234, Nov 10, 2011.

  1. simpleonline1234

    simpleonline1234 Junior Member

    Joined:
    Jan 26, 2010
    Messages:
    170
    Likes Received:
    13
    I am trying to grab the inner text of this paragraph marker but I don't have a clue as how this is to be dones because the inner text changes on refresh.
    any ideas?
    Thanks
    Code:
    <DIV class=rightcol>
    <P class=description>[B][I][U]I need to grab everything in here[/U][/I][/B]</P><INPUT id=moreoptions class="primary textbox" tabIndex=1 name=toppings[input]> <INPUT id=toppings2> </DIV></DIV></DIV>
    
     
  2. gimme4free

    gimme4free Executive VIP Premium Member

    Joined:
    Oct 22, 2008
    Messages:
    1,949
    Likes Received:
    1,949
    Code:
    Public Function GetBetween(ByVal haystack As String, ByVal needle As String, ByVal needle_two As String) As String
            Dim istart As Integer = InStr(haystack, needle)
            If istart > 0 Then
                ' Dim istop As Integer = InStr(istart, haystack, needle_two)
                Dim istop As Integer = InStr(istart + Len(needle), haystack, needle_two)
                If istop > 0 Then
                    Try
                        Dim value As String = haystack.Substring(istart + Len(needle) - 1, istop - istart - Len(needle))
                        Return value
                    Catch ex As Exception
                        Return ""
                    End Try
                End If
            End If
            Return ""
        End Function
    
        Dim Content As String = "WEBSITECONTENT"
        Dim Found As String = GetBetween(Content, "<P class=description>", "</P>")
    
     
  3. izSpK

    izSpK BANNED BANNED

    Joined:
    Sep 5, 2010
    Messages:
    1,546
    Likes Received:
    1,668
    You can use the function GetBetween in previous post, or just simply do a simple split.

    Code:
    Dim HTML As String = "<P class=description>I need to grab everything in here</P><INPUT id=moreoptions class="primary textbox" tabIndex=1 name=toppings[input]> <INPUT id=toppings2> </DIV></DIV></DIV>"
    Dim PTag As String = Split(HTML, "<P class=description>")(1)
    PTag = Split(PTag, "</P>")(0)
    
     
    Last edited: Jan 2, 2012