Results 1 to 3 of 3

Thread: [RESOLVED] Parse Code between tags

  1. #1

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Resolved [RESOLVED] Parse Code between tags

    I have the following: "<option value='78694'>God Only Knows</option>"

    The way I was going to parse it was to take the entire string, remove "</option>" and then read each character backwards until I reached ">".


    I don't like this way of doing it, as it seems slow. Could someone maybe offer a faster way to achieve this?

  2. #2
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Parse Code between tags

    Assuming there is only one set of tags in the input, something like this should work:
    VB Code:
    1. Dim sText As String, lStart As Long, lEnd As Long
    2.  
    3. sText = "<option value='78694'>God Only Knows</option>"
    4. lStart = InStr(1, sText, ">") + 1
    5. lEnd = InStrRev(sText, "<")
    6. Debug.Print Mid$(sText, lStart, lEnd - lStart)

  3. #3

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Parse Code between tags

    Worked beautifully, thanks.

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