Relative Tag Position can't find child elements within Tag

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
playwithit
Posts: 1
Joined: Sun Oct 04, 2009 1:52 pm

Relative Tag Position can't find child elements within Tag

Post by playwithit » Sun Oct 04, 2009 2:29 pm

Snippet of the Html page:
<td class="pp-contentbox-entry-noheight">
<div id="post-member-999">
<div class="pp-image-mini-wrap-floatright" style="margin-right: 10px;"></div>
<div style="margin-top: 4px;">
<img id="pp-entry-gender-img-999" border="0" alt="" src="style_images/evolution21242188117/folder_profile_portal/gender_mystery.png"/>
<strong>
<a href="http://www.iron-command.com/forum/index ... owuser=999" style="border: 2px solid rgb(0, 0, 255);">8888888</a>
</strong>

My macro v1:
TAG POS={{myvar}} TYPE=TD ATTR=CLASS:pp-contentbox-entry-noheight
TAG POS=R-1 TYPE=A ATTR=TXT:* EXTRACT=TXT
v2
TAG POS={{myvar}} TYPE=DIV ATTR=ID:post-member-*
TAG POS=R1 TYPE=A ATTR=TXT:* EXTRACT=TXT

The colour indicates what I'm hoping this will extract, however the macro is insistent on selecting links outside of the parent [the TD or the Div container in either case]. I know I'm over looking something but I tried to replicate the relative extraction shown in the DEMO-Extract tutorial as best I could and I can't see why this isnt working. Even tried different combinations of inital tag elements and experiment with using positive and negative relative positions eg: R1 and R-1, but its still goes either before or after my tagged td/div
ugh.JPG
This is a picture to attempt to clear up anything I didnt explain well enough. My paint skills are clearly lacking :P
ugh.JPG (58.49 KiB) Viewed 4059 times
Any help/responses are greatly appreciated.

edit:picture formatting
Hannes, Tech Support

Re: Relative Tag Position can't find child elements within Tag

Post by Hannes, Tech Support » Mon Oct 05, 2009 8:33 am

The HTML snipped you posted is not enough to reproduce this issue, I'm afraid.

Can you send us a complete copy of that site, or at least some part that we can test your macros on?
ABooth
Posts: 223
Joined: Mon Aug 10, 2009 4:25 pm

Re: Relative Tag Position can't find child elements within Tag

Post by ABooth » Mon Oct 05, 2009 1:26 pm

Wouldn't it be something like this: -

Code: Select all

TAG POS={{myvar}} TYPE=A ATTR=HREF:http://www.iron-command.com/forum/index.php?showuser* EXTRACT=TXT
iMacros for Firefox supports JavaScript Macros (Scripting)
JavaScript supports Java via LiveConnect

Therefore: You can write powerful macros with iMacros for Firefox. Have a look at this one

Post feature requests here. Maybe one day, they'll pin it?
josephconlin
Posts: 190
Joined: Wed Aug 06, 2008 2:38 am

Re: Relative Tag Position can't find child elements within Tag

Post by josephconlin » Mon Oct 05, 2009 8:22 pm

Hannes, iOpus wrote:The HTML snipped you posted is not enough to reproduce this issue, I'm afraid.

Can you send us a complete copy of that site, or at least some part that we can test your macros on?
Hi Hannes. I have noticed the same issue - when I use a TAG command, I cannot reference anything nested inside of that tagged item with a relative TAG command. I am always taken to the tag that matches what I'm looking for that is outside of that tag.

If you look at the source for this thread (meaning, the page we are reading right now), you will see that there is a DIV element that encloses a whole post with a class attribute of inner. Inside of that DIV, there is another DIV with a class attribute of postbody.

If I tag the first DIV with the class of inner and then try to get the first DIV with the class of postbody, I don't get the DIV that contains the first post in this thread. Instead, I get the DIV of the second post in this thread (your post that I have quoted above).

Here is a macro that you can use to see this. You will see that the first line causes the first post to be selected, and the second line, instead of getting the text of the original post, highlights and gets the text of your reply.

Code: Select all

TAG POS=1 TYPE=DIV ATTR=CLASS:inner
TAG POS=R1 TYPE=DIV ATTR=CLASS:postbody EXTRACT=TXT
PROMPT {{!EXTRACT}}
I have had to work around this in other macros by tagging something outside of the parent that I'm wanting to use, and then using relative positioning to get to the thing I want by figuring out it is at POS=2 or POS=3, etc.

This probably ought to be addressed, but please do so in a way that will not break earlier macros that were coded to work this way. Perhaps POS=R can mean what it currently does, and a new POS=I (that is the letter i, after h and before j, for InnerHTML) or something similar (POS=IR, POS=RI, etc etc) can mean drill down inside of the currently selected item.

Hope this helps.
Hannes, Tech Support

Re: Relative Tag Position can't find child elements within Tag

Post by Hannes, Tech Support » Tue Oct 06, 2009 1:39 pm

Thanks for the clarification, josephconlin.

Indeed the current "semantics" of POS=R1 is: "first occurrence after previously selected tag's 'close' tag". So you won't get "inside" a tag pair. And I see that for elements like <div>, it would be valuable to go into the tagged part.

The proposed solution using "RI" or "iR" sounds sensible to me, too.

I will forward this suggestion to the developers. Thanks again!
Hannes, Tech Support

Re: Relative Tag Position can't find child elements within Tag

Post by Hannes, Tech Support » Thu Oct 08, 2009 9:41 am

Update: the iMacros browser behaves differently, here. There, the initial (opening) tag is handled as the anchor, so R1 does reach elements inside the anchor. The developers will need to put the FF back in sync with the iMacros browser.
josephconlin
Posts: 190
Joined: Wed Aug 06, 2008 2:38 am

Re: Relative Tag Position can't find child elements within Tag

Post by josephconlin » Thu Oct 08, 2009 6:23 pm

Hannes, iOpus wrote:Update: the iMacros browser behaves differently, here. There, the initial (opening) tag is handled as the anchor, so R1 does reach elements inside the anchor. The developers will need to put the FF back in sync with the iMacros browser.
Well, I guess I'll have to rewrite some of my scripts then. Oh well. :?
Hannes, Tech Support

Re: Relative Tag Position can't find child elements within Tag

Post by Hannes, Tech Support » Fri Oct 09, 2009 7:58 am

Yes, sorry about that. But not being able to use FF scripts in the iMacros browser (or vice versa) would be too bad a choice.

However, thanks again for raising that question! Without it, we would not have noticed this difference as early.
Post Reply