Grounded XPath Resolution (GXR)
- The paper introduces GXR as a post-processing method that guarantees all fields extracted by neural models are accurately traced to their corresponding DOM nodes.
- The algorithm computes a composite score based on token overlap and fuzzy similarity to match extracted strings with their exact DOM locations.
- Empirical results demonstrate that GXR enhances traceability, significantly improving page-level F1 scores and reducing extraction errors.
Grounded XPath Resolution (GXR) is a formal post-processing mechanism developed to guarantee that every field extracted from HTML by a LLM or neural extractor is physically traceable to a unique node in the original DOM tree. By providing both the resolved value and its absolute XPath coordinate, GXR ensures 100% traceability and verifiability, correcting common failure modes where neural models hallucinate plausible outputs that do not actually appear on the page. GXR is a core component of the AXE pipeline for low-cost, cross-domain web structured information extraction, operating after model generation to attach each output to its precise DOM origin (Mansour et al., 2 Feb 2026).
1. Motivation and Conceptual Problem
Extracting structured data from heterogeneous, template-varying web pages presents the issue of "hallucinated" outputs, wherein model-generated strings may look plausible but are not present in the source HTML. This undermines downstream schema integrity, traceability, and auditability. GXR addresses this by enforcing that each extracted field in the output (e.g., in JSON or database records) is grounded—namely, matched precisely back to a node in the original DOM. Grounding is defined as the process of identifying, for each predicted string, the single DOM node whose text content most closely matches the prediction. The final output includes both the predicted value and the absolute XPath identifying its exact structural location in the document. This mechanism allows for field-level auditing and prevents non-verifiable "floating" answers (Mansour et al., 2 Feb 2026).
2. Formal Definitions
Let the DOM be modeled as a rooted, ordered tree
where is the finite set of nodes, are parent-child edges, and is the root.
- Text labels: Each node carries a label , which concatenates its visible text and that of all its descendants.
- XPath expressions: Let be the set of all absolute XPaths; each is a path from to some . There is a mapping that evaluates and returns the unique target node (or undefined).
- Grounding predicate: For an LLM prediction (a string), a scoring function is computed for every ; the best match is
The field is grounded if for some fixed threshold , that is,
The final grounded output for each field is the tuple where .
3. GXR Algorithmic Workflow
GXR operates as a deterministic, post-hoc procedure over the full, unpruned DOM. The full pipeline is as follows:
- Inputs
- The complete DOM , with no pruning to preserve all potential candidates.
- The set of extracted strings predicted by the LLM.
- A matching threshold .
- Processing
- Parse all text-bearing nodes .
- For each , score each as follows:
- Select the with maximum score; if , return . Otherwise, flag as "ungrounded."
- Outputs
- For each prediction: , or "ungrounded."
Notably, GXR does not prune the DOM—structural reductions are applied in earlier stages (specifically, by AXE’s pruner), but GXR itself performs the grounding step on the unaltered tree (Mansour et al., 2 Feb 2026).
4. Scoring Functions and Constraints
The core of GXR's matching is its composite scoring function:
where:
- weights token-level lexical overlap vs. character-level fuzzy similarity (e.g., Ratcliff–Obershelp or Levenshtein).
- Only nodes with are considered grounded.
A grounding constraint ensures that only predictions with a sufficiently strong match in the DOM are output as structured fields:
Minimal pruning (outside GXR, but relevant for context) finds the smallest node subset so that for all queries, the answer labels are retained in the text of nodes in —but for GXR, the entire is preserved as candidate space.
5. Implementation and Example
Data Structures and Efficiency
- Text nodes are indexed in a flat array, with each storing the DOM node pointer, normalized text, and precomputed token set.
- Per-prediction runtime is , being average string length. Typically, is on the order of hundreds. Fuzzy comparisons leverage optimized native libraries (e.g., Python’s
SequenceMatcher).
Illustrative Example
Given the DOM fragment:
1 2 3 4 5 |
<div id="prod"> <span class="title">UltraWidget 3000</span> <p class="price">$42.99</p> <p>Free shipping</p> </div> |
- GXR finds and as the respective best matches, both with exact string and fuzzy similarity, so outputs:
- $(\text{"\$42.99"},\ \text{"/div[1]/p[1]"},\ 1.0)$</li> </ul></li> </ul> <p>No match is assigned to "Free shipping" as that was not an extracted field.</p> <h2 class='paper-heading' id='empirical-performance-and-impact'>6. Empirical Performance and Impact</h2> <p>Ablation results on the SWDE dataset underscore GXR's importance in practical systems. Removing GXR from the AXE pipeline leads to a 4.42-point drop in page-level F1 (from 88.37% to 83.95%), constituting the single largest drop after earlier pruning. This empirically demonstrates that simple text-only generation, without field grounding, results in plausible outputs that cannot guarantee structural correctness.</p> <p>Internal evaluation on traceability metrics reports:</p> <ul> <li><strong>Grounding precision</strong> (node is correct when field appears): $\geq$98%
- Recall (fraction of predictions finding valid node with $\sigma\ge\tau\approx$96%
- Overall traceability accuracy (precision and recall): $\approx$97%
This indicates that GXR reliably maps nearly all model extractions to their genuine DOM origins and appropriately flags missing or mismatched fields (Mansour et al., 2 Feb 2026).
7. Significance for Cross-Domain Information Extraction
Grounded XPath Resolution transforms the field extraction task from one of unconstrained generation to verifiable retrieval, aligning model outputs directly with document structure. By enforcing that every output field is paired with an exact DOM coordinate, GXR creates audit trails for structured extraction and establishes domain-agnostic guarantees vital for large-scale, cross-domain web mining. Its lightweight, efficient scoring over the unpruned DOM, robust to minor string variations, is positioned as essential for high-precision, cost-efficient structured data acquisition from the web (Mansour et al., 2 Feb 2026).
References (1)