In a previous question [211112] that deals with importing data from a Wikipedia table directly into a Dataset.
For the following data:
tables = getHTMLTables[ "https://en.wikipedia.org/wiki/Comparison_of_virtual_reality_headsets"]
as given by b3m2a1 works like a charm.
However, using the function xmlTableToDataset[tab_] as given as an answer in 211112, followed by its evocation as also given, fails for a different URL containing 5 HTML generated tables. This is the case even though the 5 tables seem to be faithfully identified as XML table objects containing a list of XML-Objects for input into the xmlTableToDataset function:
tables =
getHTMLTables["http://earthwise.bgs.ac.uk/index.php/OR/14/008_Lithostratigraphical_units_used_by_BGS"];
ds = xmlTableToDataset@tables[[3]]
Mapping over the third seemingly should work since there is a 3rd table on the URL and encapsulated in the tables list.
Unfortunately, it only produces a cryptic figure of a small box as a result of the following:
ds2 = xmlTableToDataset@tables2
whereas the command:
ds2 // Keys // First // Normal
generates the error: {} has zero length and no first element
It seems that something in the xmlTableToDataset function needs generalizing. However, I can't seem to isolate the offending code even though I suspect it has to do with either the tab[[3]] construct or perhaps the Symbolic XML for the header row in the new target table that may be more complicated than expected.
How can this function be generalized to work without failure on the tables on the new target URL or other HTML tables on other URL's?
Learning how to manipulate XMLObjects still remains beyond my grasp so examples that broaden my understanding would be most appreciated as would any other approach in this instance.
NB. Strickly speaking, the above URL is not on the Wikipedia site itself but is pointed to as a reference standard in various discussions of geology. The first part (tables[1]) of table actually has no header info and only 1 row, so it can be ignored.
Import["http://earthwise.bgs.ac.uk/index.php/OR/14/008_Lithostratigraphical_units_used_by_BGS", "Data"]
$\endgroup$