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 @@ - - - - + + + + + + + +
nameagecity
Jan22Veridian City
Pieter22Pallet Town
Ash21Pallet Town
nameagecity
Jan22Veridian City
Pieter22Pallet Town
Ash21Pallet Town
\ No newline at end of file diff --git a/unittests/tests/APITestGenericHTMLTable.class.php b/unittests/tests/APITestGenericHTMLTable.class.php index 0528fbfb..9ad56898 100644 --- a/unittests/tests/APITestGenericHTMLTable.class.php +++ b/unittests/tests/APITestGenericHTMLTable.class.php @@ -16,7 +16,7 @@ class APITestGenericHTMLTable extends TDTUnitTest{ //private $location = "http://www.nieuws.be/"; //private $xpath = "//table[@id='htmlGrid_a119d7e2-e979-436a-8cad-765d37fc0fdd']"; - private $location = "/unittests/temp/person.html"; + private $location = "unittests/temp/person.html"; private $xpath = "//table"; private $install_as = "htmltablepackage/person/"; private $generic_type = "HTMLTable"; @@ -56,7 +56,6 @@ function testGetHTMLTable() { if($request->http_code != 200 && $request->result) $this->debug($request->result); } - function testDeleteHTMLTable() { $url = Config::$HOSTNAME . Config::$SUBDIR . $this->install_as; $request = new REST($url, array(), "DELETE");