0
I’ll try to be quite objective:
How do I get the value within a tag that is within 200 million other Childs ?
(understanding right away that I will not be able to make changes to the code, because it is the code of a site that I need to filter to collect specific data):
ex:
<div>
<div>
<div></div>
<div>
<div></div>
<div></div>
<h1></h1>
<div>
<div>
<div>
<h1></h1>
<div>
<div></div>
<div></div>
<table>
<tbody>
<tr></tr>
<tr></tr>
</tbody>
</table>
<div>
<div></div>
<div></div>
<div>
<div>
<div></div>
<div>
<div>
<div></div>
<table>
<tbody>
<tr></tr>
<tr></tr>
</tbody>
</table>
<div></div>
...........
For example, I need to get the information from the second table (within the tags TR)... assuming there is no id or class, as I do to get this information ?
Grateful.
If you have the basis of this structure you can use
document.getElementsByTagName('table')
and then to select use brackets ([0],[1]), and to find the TR in question repeat the process:document.getElementsByTagName('table')[0].getElementsByTagName('tr')
, if you are sure of this, use innerHTML to get the content from inside it:document.getElementsByTagName('table')[0].getElementsByTagName('tr').innerHTML
– RpgBoss
@Rpgboss Your comment is correct. If possible add as response. You can also add examples with
querySelector
andjQuery
for the answer to be quite complete.– Valdeir Psr