Q qsrtech Active Member Licensed User Longtime User May 30, 2015 #1 I need some help to extract/remove some tags within HTML. The specific one I need help with (and then I can probably take it from there for any others) is removing the "href" tag and only keeping the content for example <a href="somelink">content</a> so I only want 'content' left within the string and this has to work for multiple occurrences within the "HTML" string. Thanks EDIT: I kinda solved it with this but if you have a better way please feel free to share it Code: Copy iPos=newHTML.IndexOf("<a href=" & QUOTE) Do While iPos<>-1 'find the pos of '">' endPos=newHTML.IndexOf2(QUOTE & ">",iPos) sSub=newHTML.SubString2(iPos,endPos+2) newHTML=newHTML.Replace(sSub,"") iPos=newHTML.IndexOf("<a href=" & QUOTE) Loop Last edited: May 30, 2015
I need some help to extract/remove some tags within HTML. The specific one I need help with (and then I can probably take it from there for any others) is removing the "href" tag and only keeping the content for example <a href="somelink">content</a> so I only want 'content' left within the string and this has to work for multiple occurrences within the "HTML" string. Thanks EDIT: I kinda solved it with this but if you have a better way please feel free to share it Code: Copy iPos=newHTML.IndexOf("<a href=" & QUOTE) Do While iPos<>-1 'find the pos of '">' endPos=newHTML.IndexOf2(QUOTE & ">",iPos) sSub=newHTML.SubString2(iPos,endPos+2) newHTML=newHTML.Replace(sSub,"") iPos=newHTML.IndexOf("<a href=" & QUOTE) Loop
Q qsrtech Active Member Licensed User Longtime User Jun 2, 2015 #3 NJDude said: You can try THIS or THIS Click to expand... Thanks. I already looked at the first post but couldn't figure out how to translate it to my situation. The second post works great for removing all tags. Upvote 0
NJDude said: You can try THIS or THIS Click to expand... Thanks. I already looked at the first post but couldn't figure out how to translate it to my situation. The second post works great for removing all tags.
S sorex Expert Licensed User Longtime User Jun 2, 2015 #4 you could use Code: Copy links=Regex.Matcher("<a href=""(.*?)"">(.*?)</a>",myHTML) to grab and loop through all hyperlinks and pick only the title. Upvote 0
you could use Code: Copy links=Regex.Matcher("<a href=""(.*?)"">(.*?)</a>",myHTML) to grab and loop through all hyperlinks and pick only the title.
Q qsrtech Active Member Licensed User Longtime User Jun 2, 2015 #5 Ok thanks I will check it out later. The "regular expressions" are powerful but i don't use it enough to really spend a lot of time to learn the ins and outs. Maybe one day... Upvote 0
Ok thanks I will check it out later. The "regular expressions" are powerful but i don't use it enough to really spend a lot of time to learn the ins and outs. Maybe one day...
I inakigarm Well-Known Member Licensed User Longtime User Jun 2, 2015 #6 Check Jsoup html parser; it' s very easy !! https://www.b4x.com/android/forum/threads/jsoup-html-parser.49152/ Upvote 0
Check Jsoup html parser; it' s very easy !! https://www.b4x.com/android/forum/threads/jsoup-html-parser.49152/