diff --git a/model/resources/strategies/HTMLTable.class.php b/model/resources/strategies/HTMLTable.class.php index 5260eb33..505a57df 100644 --- a/model/resources/strategies/HTMLTable.class.php +++ b/model/resources/strategies/HTMLTable.class.php @@ -77,6 +77,10 @@ public function onCall($package,$resource){ $domxpath = new DOMXPath( $html ); $tablerows = $domxpath->query($xpath . "/tr" ); + if ($tablerows->length == 0) { + //table has thead and tbody + $tablerows = $domxpath->query($xpath . "/*/tr" ); + } $rowIndex = 1; foreach ($tablerows as $tr) { @@ -86,6 +90,10 @@ public function onCall($package,$resource){ $domxpath = new DOMXPath( $newDom ); if ($rowIndex == 1) { $tablecols = $domxpath->query("td"); + if ($tablecols->length == 0) { + //thead row has th instead of td + $tablecols = $domxpath->query("th" ); + } $columnIndex = 1; foreach($tablecols as $td) { $fieldhash[ $td->nodeValue ] = $columnIndex; diff --git a/unittests/temp/person.html b/unittests/temp/person.html index 4d1cf376..20e50c7b 100644 --- a/unittests/temp/person.html +++ b/unittests/temp/person.html @@ -1,8 +1,12 @@
name | age | city |
Jan | 22 | Veridian City |
Pieter | 22 | Pallet Town |
Ash | 21 | Pallet Town |
name | age | city |
---|---|---|
Jan | 22 | Veridian City |
Pieter | 22 | Pallet Town |
Ash | 21 | Pallet Town |