IAMK Posted September 24, 2018 Posted September 24, 2018 I was wondering if there is any way to know which line or position in the source of a webpage a certain tag is from? E.g. Local $spanTags = _IETagNameGetCollection($ie, "span") For $spanTag In $spanTags Consolewrite($spanTag.location & ": " & _IEPropertyGet($spanTag, "InnerText") & @CRLF) Next The reason I want this is because I have a mixture of span/div/li tags, which I want to log the information of in the same order as their appearance in the source. My solution to this was to parse through span tags and store them in an array. Repeat for div and li tags. Then, I do a greater/less check on the 3 arrays, giving me 1 final sorted array.
mikell Posted September 24, 2018 Posted September 24, 2018 (edited) Maybe something like this (untested) Local $Tags = _IETagNameAllGetCollection($ie) For $Tag In $Tags $tagname = $Tag.tagname If not StringRegExp($tagname, '(?i)span|div|li') Then ContinueLoop Consolewrite($tagname & ": " & _IEPropertyGet($Tag, "InnerText") & @CRLF) Next as the help file says :_IETagNameAllGetCollection : Returns a collection object all elements in the document or document hierarchy in source order Edited September 24, 2018 by mikell
IAMK Posted September 24, 2018 Author Posted September 24, 2018 @mikell Thanks, that will do the trick.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now