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.
1 Answer
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.
2 Comments
Jyotish Singh
Thanks for your solution but is there any parser available through which i could parse Html as we can do with Xml?
gazzz0x2z
I wrote that code because I didn't have that answer, about a tool. Would take me a few hours to write a full tool with some functionalities, I guess. Based on what I wrote here.