How to use the PHP DOM Parser to parse the content of the table, so I get:
- the username
- the mobilephone number
- the status
So the output of what I try to extract would be:
- randomusername - 0123456789 - active
- randomusername2 - 0987654321 - active
This is the html i try to parse (some part of it):
...
<div class="table tbl-process-mobile">
<div class="table-cn">
<div class="table-bd">
<table cellspacing="0" id="idd7">
<thead>
<tr id="idd9">
<th scope="col">
<span>username</span>
</th>
<th scope="col">
<span>status</span>
</th>
<th scope="col">
<span>prefered number</span>
</th>
<th scope="col">
<span>action</span>
</th>
</tr>
</thead>
<tbody id="iddb">
<tr class="even">
<td class="even">
<div>randomusername</div>
</td><td class="odd">
<div>0123456789</div>
</td><td class="even">
<div>active</div>
</td><td class="odd">
<div>
<span id="iddc" style="display:none"></span>
<a href="xyz" id="idb2"><span>set number</span></a>
</div>
</td><td class="even">
<div>
<a id="iddd" style="display:none"></a>
<a href="xyz" class="action-icon-edit" id="idb3" title="change">
<i>change</i>
</a>
<a href="xyz" class="action-icon-delete" id="idb4" title="delete">
<i>delete</i>
</a>
</div>
</td>
</tr><tr class="odd">
<td class="even">
<div>randomusername2</div>
</td><td class="odd">
<div>0987654321</div>
</td><td class="even">
<div>active</div>
</td><td class="odd">
<div>
<span id="idde" style="display:none"></span>
<a href="xyz" id="idb5"><span>set number</span></a>
</div>
</td><td class="even">
<div>
<a id="iddf" style="display:none"></a>
<a href="xyz" class="action-icon-edit" id="idb6" title="change">
<i>change</i>
</a>
<a href="xyz" class="action-icon-delete" id="idb7" title="delete">
<i>delete</i>
</a>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
...
I already started with some PHP code:
<?php
error_reporting(0);
$matches = array();
$dom = new DOMDocument;
$dom->loadHTMLFile('settings.html');
How to extract the values, what's the best way to parse the HTML from this point?
tr.error_reporting(0);won't help. It's best to catch and display during testing.