dom - php - Having Issues extracting link information from within multiple nested tables and div using DOMXPath -
i'm trying extract specific link attributes within multiple nested table structure. document format old, explain rampant use of table element design page.
here relevant document i'm trying parse using domxpath:: each table width of 100% has 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 code i'm using parse it. i'm trying value of href , textvalue of anchor nested deep within 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 $this->eachnodes) { echo $this->eachnodes; } error_reporting(1); }
this doesn't works @ all. i've tried changing query parameters match document structure without avail. var_dump returns.
object(domnodelist)#44 (1) { ["length"]=> int(0) }
how extract anchor attributes each of divs within inner table has width of 100%. in case return href="owlbook/manufacturer.aspx?manufacturerid=124" , textvalue = owl chant book
please provide sort of help, don't think i'm making progress in finding viable solution.
thanks, maxx
Comments
Post a Comment