read html tag line by line and find a value

CarcaBot

Well-known member
Joined
Apr 23, 2007
Messages
47
Location
Romania
Programming Experience
Beginner
assuming i have http://wwww.mysite.com/index.htm

how to read line by line in the index.htm and search a value "TEST" in all line of documet html, and when is found store in MY_VAR....

or/and

in index.htm i have following:
<mytag>value</mytag>

how to read what's in <mytag>*</mytag>

Thanks In advance.
 
What you need to do is to find the start and stop position of the string you want and copy it out. There are many different functions you can use to accomplish this but it basically use the same concept.

Dim StartPos, StopPOS As Integer
Dim TempStr As String = "<mytag>VB City</mytag>"
Dim ResultStr As String
StartPos = TempStr.IndexOf("<mytag>") + 7 'add the offset of the tag
StopPOS = TempStr.IndexOf("</mytag>")
ResultStr = TempStr.Substring(StartPos, StopPOS - StartPos)

You might want to look up on the following functions: InStr, InStrRev, Mid, IndexOf, SubString, Insert, Remove, Replace...
 
Back
Top