Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse Html string(Not File) in VBScript

I am having a html string (Don't have any kind of file and don't want to first save my string as a html file then load it) and I want to get some link and text between certain tags. I tried to search but did't find any luck. Could someone help me to solve this issue. Thanks in advance.

like image 893
Jyotish Singh Avatar asked Dec 14 '15 06:12

Jyotish Singh


1 Answers

Well, I don't know the tools well enough, so let's do it manually; first, let's kick off unwanted carriage returns :

myChain = Replace(myChain, Chr(13), "")
myChain = Replace(myChain, Chr(10), "")

Now, let's find the first occurence of the tag :

beginLink = Instr(1, myChain, "<mytag>") + Len("<mytag>")
endLink = Instr(1, myChain, "</mytag>")
lenLink = endLink - beginLink
myLink = Mid(myChain, beginLink, lenLink)

And if You need to look for a subsequent occurence of the same tag, replace the 1 by the end of the previous tags

newPosition = endLink + Len("<mytag>")
beginLink = Instr(newPosition , myChain, "<mytag>") + Len("<mytag>")
endLink = Instr(newPosition , myChain, "</mytag>")

etc...

I leave you to do a proper loop there.

like image 133
gazzz0x2z Avatar answered Nov 18 '22 11:11

gazzz0x2z