i'm trying to extract specific link attributes from within a multiple nested table structure. The document format is old, which would explain the rampant use of table element to design the page.
Here is the relevant document which i'm trying to parse using DOMXPath:: Each table with a width of 100% has the same level of nested childs, i.e. tbody, tr, td, a, div, etc.
<table width="1000px">
<tbody>
<tr></tr>
<tr>
<td>
<br>
<span></span>
<span></span>
<div></div>
<div>
<div></div>
<div>
<center></center>
<hr>
<table width="100%"></table>
<table width="100%">
<tbody>
<tr>
<td>
<a name="A"></a>
<div style="width: 230px;">
<a href="owlbook/manufacturer.aspx?manufacturerId=124">Owl Chant Book</a>
<br>
</div>
</td>
</tr>
</tbody>
</table>
<table width="100%"></table>
<table width="100%"></table>
<table width="100%"></table>
<table width="100%"></table>
<table width="100%"></table>
<table width="100%"></table>
<table width="100%"></table>
<table width="100%"></table>
<table width="100%"></table>
<table width="100%"></table>
<table width="100%"></table>
<table width="100%"></table>
<table width="100%"></table>
<table width="100%"></table>
<table width="100%"></table>
</div>
</div>
</td>
</tr>
</tbody>
</table>
And here is the code which i'm using to parse it. I'm trying to get the value of the href and the textValue of the anchor nested deep within the divs.
public function parseManufacturerNodes($results) {
error_reporting(0);
$this->dom = new DOMDocument();
$this->dom->loadHTML($results);
$this->domQuery = new DOMXPath($this->dom);
$this->nodes = $this->domQuery->query("//table/tbody/tr/td/div/div/div/div/table/tbody/tr/td/div");
var_dump($this->nodes);
foreach ($this->nodes as $this->eachNodes) {
echo $this->eachNodes;
}
error_reporting(1);
}
This doesn't works at all. I've tried changing the query parameters to match the document structure without any avail. var_dump returns.
object(DOMNodeList)#44 (1) { ["length"]=> int(0) }
How would i extract the anchor attributes from each of the divs within the inner table which has a width of 100%. Which in this case would return href="owlbook/manufacturer.aspx?manufacturerId=124" and textValue = Owl Chant Book
Please provide any sort of help, as i don't think i'm making any progress in finding a viable solution.
Thanks, Maxx