
Parsing Nested XML from Flying Probe Testers into a Relational Database
Flying Probe Tester XML files are large, deeply nested and change namespaces between firmware versions, so I parse them with a three-table schema and defensive streaming code.
- Published
- March 30, 2026
- Author
- Hrushiekesh Reddy Kanjula
- Read time
- ~4 min
- Category
- engineering

A Flying Probe Tester (FPT) validates PCBs electrically. It has no custom bed-of-nails fixture. Motorized probes move across the board, touch test points and measure resistance, capacitance and continuity. For each board, it writes an XML report. Some are 5,000 nodes deep. They describe every probe measurement, every pass/fail result and every board-level attribute.
Getting that XML into a queryable database is hard for three reasons. The nesting is deep. The schema drifts between firmware versions. The files are large enough that DOM parsing runs out of memory on edge hardware. Here is how I handle each.
The three-table schema
Hierarchical XML maps well to three tables with cascading foreign keys.
| Table | One row per | What it holds |
|---|---|---|
fpt_imports | File import | File path, import timestamp, operator, overall pass/fail summary. It anchors everything downstream. |
fpt_board_results | Board tested in the file | Board serial number, board-level pass/fail, test duration, temperature at time of test. A single FPT run often tests several boards in a panel. Foreign key to fpt_imports. |
fpt_component_tests | Individual probe measurement | Reference designator, pin identifiers, measured value, expected value, tolerance, pass/fail status. One board generates hundreds to thousands of these rows, one per component pin pair tested. Foreign key to fpt_board_results. |

You can query at any level. "How many boards passed today?" hits fpt_board_results. "Which pin pairs are failing on resistor R47 across all boards this week?" hits fpt_component_tests, joined to fpt_board_results.
Namespaces change between firmware versions
FPT XML files use namespaces, declarations like xmlns:fpt="http://vendor.com/fpt/v2". Namespaces are meant to keep schemas stable across versions. In practice, the vendor updates firmware and silently changes the namespace URI. Every namespace-aware parser that references the old URI then breaks.
My fix is namespace-agnostic parsing. I use lxml and strip the Clark-notation namespace from each tag.
from lxml import etree
def strip_namespace(element):
"""Remove namespace prefix from tag name."""
if '}' in element.tag:
element.tag = element.tag.split('}', 1)[1]
for child in element:
strip_namespace(child)
return element
def parse_fpt_file(filepath: str) -> etree._Element:
tree = etree.parse(filepath)
root = tree.getroot()
return strip_namespace(root)After stripping, XPath queries use bare tag names, such as ".//BoardResult" instead of ".//fpt:BoardResult". When the vendor changes the URI in the next firmware release, the parser still works.

Streaming parse for large files
A full production shift can produce an FPT XML file over 500MB. etree.parse() loads the whole document into memory. That is fine for small files. For large ones, the Python process exhausts the RAM on edge hardware.
The fix is etree.iterparse(). It reads the document as a stream and yields elements as it reaches them. The important part is the clear() call, which discards each element after it is processed.
def stream_parse_component_tests(filepath: str):
context = etree.iterparse(filepath, events=("end",), tag="ComponentTest")
for event, elem in context:
yield {
"ref_des": elem.findtext("RefDes"),
"pin_a": elem.findtext("PinA"),
"pin_b": elem.findtext("PinB"),
"measured": float(elem.findtext("Measured") or 0),
"expected": float(elem.findtext("Expected") or 0),
"passed": elem.findtext("Result") == "PASS"
}
elem.clear() # ← critical: discard from memory after processingMemory stays flat regardless of file size. A 500MB file processes in a constant memory footprint of about 40MB.
Bulk insert
A board has thousands of component test rows. Inserting them one at a time takes minutes. SQLite's executemany() inside a single transaction cuts that to seconds.
def bulk_insert_component_tests(conn, board_id: int, tests: list[dict]):
rows = [(board_id, t["ref_des"], t["pin_a"], t["pin_b"],
t["measured"], t["expected"], t["passed"]) for t in tests]
conn.executemany("""
INSERT INTO fpt_component_tests
(board_id, ref_des, pin_a, pin_b, measured, expected, passed)
VALUES (?, ?, ?, ?, ?, ?, ?)
""", rows)
conn.commit()The transaction matters. By default, SQLite commits after each insert, which means thousands of disk syncs. One transaction means one sync for the whole batch.

Queries this enables
Once the data is in the three tables, some queries become simple. The assembly hub's analytics layer uses these regularly.
- Component failure rate by family. Join
fpt_component_teststo the canonical component library onref_des, group by family and compute the pass rate. It shows right away whether capacitors or resistors are driving failures this week. - Board-to-board variation for the same part. Pull all
fpt_component_testsrows for oneref_desacross a date range and plot the distribution ofmeasured. A tight distribution means stable placement. A wide one points to a machine or material problem. - Marginal pass analysis. Filter for rows where
passed = TRUEbutABS(measured - expected) / expected > 0.8. These components passed, but they are operating near their tolerance limit. That is an early warning of future failures.
The pipeline took real work to build. It pays back each time an engineer uses the data to diagnose a production issue before it becomes a field return.