Send Feedback
Skip to content

The Expat Module in KDB-X

This page provides an overview of the Expat module in KDB-X.

The Expat module for KDB-X integrates the Expat XML parser library, enabling fast, incremental XML parsing directly in q code.

Unlike document-based parsers that load an entire XML tree into memory, Expat uses a stream-oriented approach – reading XML incrementally and triggering callback functions as it encounters elements such as start tags, end tags, text nodes, comments, and processing instructions. This makes it well-suited for processing large or continuous XML data streams within KDB-X environments.

Key features

  • Event-driven parsing – callbacks fire as XML is read, giving you fine-grained control over how data is handled.
  • High performance and low memory usage – powered by the Expat C library for optimal speed without loading the full document into memory.
  • Multiple character encoding support – works with UTF-8, UTF-16, and other encodings out of the box.
  • Seamless q integration – accessible through intuitive function calls within the KDB-X ecosystem.
  • Distributed through Fusionx – installed and updated as part of the Fusionx module.

Use cases

Use the Expat module for:

  • Ingesting XML data feeds to extract structured fields from financial, market, or telemetry data in XML format.
  • Streaming large XML files where loading the full document into memory would be impractical.
  • Real-time XML processing to parse and react to XML data as it arrives in a KDB-X pipeline.
  • Data transformation to convert XML-formatted inputs into q tables or other KDB-X structures.

Next steps

  • Refer to the Expat documentation on GitHub for API references and instructions on how to install and update the module.