## TL;DR
Parse the HTML with a DOM parser and select tables by their captions or headers, not by position: nested tables break flat parsers because inner rows appear as part of the outer table. Walk the document tree, extract each table whose header matches the wanted shape, and validate extracted numbers against the report's own totals where present.

```text
parser failed on HTML experiment reports with nested tables and threw a parse error
```

## Use this when
- The run or call fails with this symptom: parser failed on HTML experiment reports with nested tables.
- You are working on an agent extracting results from HTML experiment reports and the failure repeats on the same run or configuration.
- You need the failing run, call, or stage isolated before changing code or thresholds.

## Not for this skill when
- A report whose data lives in a chart image rather than tables, where extraction needs the underlying data file instead.
- The error text names a different tool, stage, or root cause. Match the verbatim error first and use that skill.

## Steps
1. Load the report into a DOM parser and list its tables with their captions and header rows. Verify: the table inventory is known
2. Identify which tables hold results and which are layout or nested detail tables. Verify: target tables are selected by identity
3. Extract cell values from the target tables only, preserving row labels alongside the numbers. Verify: extracted rows carry their labels
4. Cross-check a few extracted totals against the report's summary figures before using the data. Verify: extraction accuracy is sampled and confirmed

## Variant phrasings
### parser failed html experiment reports nested tables agent
The verbatim phrasing.
### agent extract results html report nested table dom fix
The DOM phrasing.
### html report parsing agent tables layout merged rows
The merged-rows phrasing.

Compatibility: Agent parsers reading HTML experiment reports with nested tables

## Why it happens
HTML tables nest legitimately for layout and drill-downs, so a stream parser that flattens tags merges inner and outer rows into nonsense. The document tree keeps the nesting explicit, and header-based selection finds data by meaning rather than by position in a fragile layout.

## Edge cases / pitfalls
- Reports generated by different tools nest differently; sample each source's structure before trusting one extractor.
- Merged cells span rows and columns in the tree; account for spans or values shift silently.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_un2OgS081QRq1WmpPqaM7Q
