Jump to content

Get all HMTL elements with same ID - not in table


Jfish
 Share

Go to solution Solved by Gianni,

Recommended Posts

I apologize for the simplicity of this question - I don't know much about HTML elements and I did a search on the forum first.

I just started using the _IETableWriteToArray function in some of my project and I love it because it allows me to easily grab lists and stuff them in an array.  Now I am trying to do the same thing with some HTML that does not use tables.  However, the HTML IDs for the sections containing the data I want to read repeat themselves throughout.  Example (where "foobar" is repeated throughout):

<div id="foobar" style="width: 440px; float: left; padding-left: 10px">DATA<br>MORE DATA<br>MAORE DATA<br>MORE DATA</div>

I know that I can refer to a given element like this:

Local $element = _IEGetObjById($oIE, "foobar")

However, I am wondering what is the best way to grab the values of all the same ID elements and get them into an array? Any guidance would be appreciated.

JFish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

@Chimp -

Thanks, that does help a lot.  It brings back everything including all tags etc but I can parse a lot of that out.  I recently saw a post where someone was using jquery and au3.  They did something like this:

$testValue= $oIE.document.parentWindow.jQuery('#objectID').val()

I don't know much about jquery but I believe that would probably eliminate the need to whittle down the innerhtml that comes back.  Are you familiar with that approach?  Could that be used to get a collection of the values that I am after while ignoring the html? 

EDIT: I also noticed that the :

$element.InnerHTML

Only seems to work for the first element with that ID.  If there is more than one the others seem to be ignored.  Any ideas on that?





			
				


	Edited  by Jfish
	
	

			
		

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

  • Solution

 

@Chimp -

Thanks, that does help a lot.  It brings back everything including all tags etc but I can parse a lot of that out.  I recently saw a post where someone was using jquery and au3.  They did something like this:

$testValue= $oIE.document.parentWindow.jQuery('#objectID').val()

I don't know much about jquery but I believe that would probably eliminate the need to whittle down the innerhtml that comes back.  Are you familiar with that approach?  Could that be used to get a collection of the values that I am after while ignoring the html? 

 

.. not familiar with jQuery

you could also try with the InnerText property,

 

EDIT: I also noticed that the :

$element.InnerHTML

Only seems to work for the first element with that ID.  If there is more than one the others seem to be ignored.  Any ideas on that?

In an HTML page there should be only one element with a specific ID, in fact a specific ID can be assigned to only a single element

If you see more elements with the same ID maybe is because you are in presence of "frames", that is like if you have more pages in the same page, so, if you want to refer to elements of different pages (frames), you need to get references to single frames first.

have a look to >this link for an "authoritative" explanation :)

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...