Free course · 12 lessons · Advanced

XML in Production

The XML failures that reach production and how to prevent them: namespace changes that silently empty an import, encoding corruption, XML injection, empty-versus-missing values, memory blow-ups on large feeds, quadratic XPath, XXE and entity-expansion attacks, schema drift between partners and broken signatures, with runnable simulations and two capstone case studies.

Start the course

1. Data Correctness

The quiet failures: XML that parses fine but means something different from what the code assumes.

  1. The Import That Found Zero Orders — A partner added a default namespace to its order feed. Every XPath query silently returned nothing, and the nightly import reported success with zero orders.
  2. Müller Became Müller — Customer names with accents came out garbled after an XML export was decoded with the wrong encoding, then saved and sent on to other systems.
  3. The Customer Named </name><admin>true</admin> — An order service built XML by string formatting. A company name with an ampersand broke every export, and a crafted value changed the document's structure.
  4. The Discount That Became Zero — An optional discount element was sometimes empty, sometimes missing and sometimes nil. The code treated all three the same, and a pricing rule zeroed out discounts.

2. Performance at Scale

XML code that works on a sample file and falls over on real volumes: memory blow-ups and accidentally quadratic queries.

  1. The 4 GB Product Feed — A product import loaded a supplier feed into a DOM. When the feed grew to 4 GB, the worker was killed for running out of memory every night.
  2. The Report That Took 40 Minutes — A reconciliation script looked up each order's customer with an absolute XPath inside a loop. It was instant on test data and took 40 minutes on a month of production data.

3. Security and Integration

Parsers that read files they shouldn't, documents that expand into gigabytes, contracts that drift, and signatures that break on whitespace.

  1. The Upload That Read the Server's Files — An invoice-upload endpoint parsed XML with external entities enabled. A tester uploaded a document that echoed the server's configuration file back in the error message.
  2. The 1 KB Request That Took the API Down — A SOAP endpoint expanded nested internal entities. One small request expanded to gigabytes in memory and took every worker down.
  3. The Partner's New Field Broke Our Validator — A partner added an optional element to its messages. The receiver's strict schema rejected every message, stopping order flow for six hours.
  4. The Signed Message That Failed Verification — A payment message signed by the sender failed verification after a gateway pretty-printed it. Byte-level hashing of XML broke on harmless formatting changes.

4. Capstone Case Studies

Design a safe, scalable ingestion pipeline for partner XML, and investigate an invoicing incident end to end.

  1. Capstone: A Safe, Scalable XML Ingestion Pipeline — Design the pipeline that receives, validates, transforms and loads XML from 200 partners, from 2 KB messages to 6 GB nightly files.
  2. Capstone: Postmortem — The Invoices That Lost Their Totals — Write the postmortem for an incident in which 3,400 invoices were sent to customers with a total of 0.00 after a supplier system upgrade.

Was this page helpful?