I have an HTML Table and its each rows are identified with an unique id. I'm trying to get the label text inside one of row. I tried with $dom->getElementById($id); but this provides all text values coming under that element.
Here is the structure:
<table>
<tr id="1">.....</tr>
<tr id="2">
<td>
<span>Some text</span>
</td>
<td>
.
. //Some html elements
.
<table>
<tbody>
<tr>
<td>
<label>label1</label>
</td> //I want to collect these labels
<td>
<label>label2</label>
</td>
</tr>
</tbody>
</tabel>
.
.
.
I tried with this $elements = $dom->getElementById('2'); code. It provides all values together.
Output
["nodeValue"]=> string(37) "Select your options *option 1option 2"
How can I get only label text.