How do I extract ALT text from here (Please check the code)?

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
User avatar
rajtak
Posts: 26
Joined: Mon May 11, 2009 3:57 am
Contact:

How do I extract ALT text from here (Please check the code)?

Post by rajtak » Tue May 29, 2012 4:09 am

Please help me in writing code to extract ALT text from the code below:

Output should be 'Sperry Van Ness' only

Code: Select all

<div id="ProfileMainContent1_ProfileOptionContent1_BrokerContact1_divCompanyImageName" class="contactModule brokerage">
	        <p>Presented by</p>              
	        <p><a id="ProfileMainContent1_ProfileOptionContent1_BrokerContact1_lnhlBrokerageFirm" href="/xNet/MainSite/LoopNetFrame/Frame.aspx?LID=17681180&ExposureStatistic=Profile&AssociateID=1800416&PgCxtGuid=9dc5575e-2bc0-4b69-b2e6-87558bf677f8&PgCxtFLKey=&PgCxtCurFLKey=Profile&PgCxtDir=Down&LoopNetFrameUrl=http://www.svn.com"><img alt="Sperry Van Ness" src="http://www.loopnet.com/Attachments/2/2/5/2252e06d-56ee-42dc-978f-8f148a508962.jpg" /></a></p>
	        <p></p>
        </div>
I have tried this but not working

Code: Select all

TAG POS=1 TYPE=DIV ATTR=ID:ProfileMainContent1_ProfileOptionContent1_BrokerContact1_divCompanyImageName
TAG POS=R1 TYPE=IMG ATTR=SRC:http://www.loopnet.com/Attachments/* Extract=ALT
Thank you in advance.
Thanks,
Raj
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: How do I extract ALT text from here (Please check the co

Post by siniy » Sat Jun 02, 2012 8:59 pm

Relative positioning doesn't work in this case. Image inside the div tag, it is not the next tag.
For nested tags xpath works better. Firebug has wonderfull xpath addon - firepath.

Code: Select all

TAG XPATH="//div[@id="ProfileMainContent1_ProfileOptionContent1_BrokerContact1_divCompanyImageName"]/p[2]/a/img" EXTRACT=alt
You can change div id

Code: Select all

TAG XPATH="//div[@id="ProfileMainContent1_ProfileOptionContent1_BrokerContact{{!LOOP}}_divCompanyImageName"]/p[2]/a/img" EXTRACT=alt
Post Reply