6

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 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your solution but is there any parser available through which i could parse Html as we can do with Xml?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.