I would use an anonymous function in Javascript to parse the table and return the contents as an array of array of strings. This will be easier to parse in C#.
See http://jsfiddle.net/stevejansen/xDZQP/ for an example of parsing a table in Javascript. (Sidenote: I would check to see if your data source provides a REST API or similar to access this data; parsing HTML is really fragile.)
This is roughly how I would combine C# and JS to solve your problem (the C# is untested). Note you were using the wrong return type for IWebView.ExecuteJavascriptWithResult
.
const string JAVASCRIPT = @"(function () {
var table = document.getElementById('production_table'),
records = [];
if (table == null) return;
table = table.getElementsByTagName('tbody');
if (table == null || table.length === 0) return;
// there should only be one tbody element in a table
table = table[0];
// getElementsByTagName returns a NodeList instead of an Array
// but we can still use Array#forEach on it
Array.prototype.forEach.call(table.getElementsByTagName('tr'),
function (row) {
var record = [];
Array.prototype.forEach.call(row.getElementsByTagName('td'),
function (cell) {
record.push(cell.innerText);
});
records.push(record);
});
return records;
})();";
JSValue result = view.ExecuteJavascriptWithResult(JAVASCRIPT);
JSValue[] records;
JSValue[] record;
if (result.IsNull || !result.IsArray)
return;
records = (JSValue[])result;
foreach(JSValue row in records)
{
if (row == null || row.IsNull || !row.IsArray)
continue;
record = (JSValue[])row;
foreach(JSValue cell in record)
{
if (cell.IsNull || !cell.IsString)
continue;
System.Diagnostics.Debug.WriteLine((string)cell);
}
}