Results 1 to 4 of 4

Thread: [RESOLVED] Read line between specific tag (local html)

Threaded View

  1. #1

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Resolved [RESOLVED] Read line between specific tag (local html)

    Ola,

    How do I read/get text/line between specific text. For example:

    my html-file contains
    <title>This is my Title</title>

    I have found a code, which I needed to convert from C#, but it doesn't work:

    Code:
    Private Shared Function GetTitle(html As String) As String
       Dim r As New Regex("<title.*?>")
       Dim Title_start As Integer = 0
       Dim Title_end As Integer = 0
       For Each m As Match In r.Matches(html)
          If m.Value.ToLower = "<title>" Then
             Title_start = m.Index + m.Length
             Exit For
          End If
       Next
       r = New Regex("</title.*?>")
       For Each m As Match In r.Matches(html)
          If m.Value.ToLower = "</title>" Then
             Title_end = m.Index - Title_start
             Exit For
          End If
       Next
       Dim title As String = html.Substring(Title_start, Title_end)
       Return title
    End Function
    I have a textbox which get's its value from the Url.Tostring on DocumentCompleted. For example: I have loaded a local html-file, the Url,Tostring would be file:///C:/page.html so I need to call it like:
    Code:
    GetTitle(textbox.text)
    Unfortunately, it doesn't work.

    I have already loaded the html-text into a rtb, so perhaps is easier to extract it from there.

    Thanks in advance.
    Last edited by Radjesh Klauke; Mar 30th, 2011 at 02:03 AM.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

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
  •  



Click Here to Expand Forum to Full Width