View Single Post
  #1 (permalink)  
Old February 6th, 2008, 02:36 AM
boniggy boniggy is offline
Registered User
Join Date: Feb 2008
Location: Chandler, Arizona, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to boniggy Send a message via MSN to boniggy
Default Trying to pull data between two different HTML tag

Ok so im a complete n00b at using vb.NET as i have been used to using
vb6 for a little over a year. I'm sort of forcing myself to
learn .NET.

Anyways im working on a project that parses a webpage of its data. The
data I need to pull is between the tags of <div class="description">
and </ul>. If i could pull this data it would be great. The only
problem i have is that my program currently starts at the first
"description" tag and then parses everything else in to the bottom of
the page. I cant seem to figure out why it wont stop at the last </ul>

Here is the code for the portion im talking about:

            'get the response from the server
            responseReader = New IO.StreamReader(webRequest.GetResponse.GetResponseStream)
            responseData = responseReader.ReadToEnd
            strData = responseData

            Dim intIndex As Integer
            Dim intLastIndex As Integer
            Dim strInfo As String 
            strInfo = ""
            intIndex = strData.IndexOf("<div class=""description""",
            intLastIndex = intIndex

            While intIndex >= 0

                intIndex = strData.IndexOf("</ul>", intIndex)

                If intIndex >= 0 Then
                    strInfo += strData.Substring(intLastIndex,
intIndex - intLastIndex) + "</ul>"
                    intLastIndex = intIndex
                    intIndex = strData.IndexOf("<div
class=""description""", intLastIndex + 1)
                    intIndex = -1
                End If
            End While
I then take the data that gets parsed and put it into a txt or html
file. Personally i think it might be ReadToEnd at the top of the
If i've left anything out that you need please let me know. Like
i said im still learning programming so if its too cryptic I may
answer back with an explanation.

Any help would be GREATLY appreciated and thank in advance!


Reply With Quote