php - Parsing A Table, Can't get more than 3 row Using DOMXpath -


for wierd reason can't understand right can't fetch more 3 row table in page

this page.

http://www.reedmfgco.com/en/products/cutters-and-cutter-wheels/cutter-wheels/cutter-wheels-for-tubing-cutters-plastic/

i want parse table @ bottom.

since there 1 table in page made xpath simple.$xpath -> query('//tr')

if following

echo $xpath -> query('//tr')->lenght; 

i 3

why getting 3 there 9 row there, should 9.


edit code use

$dom = new domdocument(); @$dom -> loadhtml($this->html); $xpath = new domxpath($dom); echo $xpath -> query('//tr')->lenght; 

and please note $this->html raw html previous link in post.

html source on page not valid xml. if open source code of page , tag <tr>, has 3 elements. table row products not have opening tag <tr>

for problem, can use regular expressions normalize contents of table.

$html = file_get_contents('http://www.reedmfgco.com/en/products/cutters-and-cutter-wheels/cutter-wheels/cutter-wheels-for-tubing-cutters-plastic/');  preg_match('`<tbody>(.*)<\/tbody>`', $html, $matches); if (!empty($matches)) {     $tablebody = str_replace('</tr><td', '</tr><tr><td', $matches[1]); } 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -