🚀 High-Performance XML Processing
Benchmarked XML parser optimized for speed and memory efficiency. Outperforms traditional DOM parsers for large XML files. See Performance Benchmarks
writeEvent() connects EventReader and EventReaderSync directly to every
writer. XML declaration metadata, namespace declarations, attributes, and
self-closing syntax stay available while your code replaces only the events it
needs. For allocation-sensitive transformations, pair a StreamReader with the
writer’s individual stream methods instead.
Build an XML transformation pipeline →
🚀 High-Performance XML Processing
Benchmarked XML parser optimized for speed and memory efficiency. Outperforms traditional DOM parsers for large XML files. See Performance Benchmarks
🔄 Streaming XML Parser
Memory-efficient parsing and read-modify-write pipelines. Process XML files of any size without loading the entire document. Learn Streaming API
🌐 Browser and Runtime Compatibility
Works in Node.js, Bun, Deno, and modern browsers through the same pure JavaScript parser core. Installation Guide
📝 TypeScript-First XML Parser
Built with TypeScript, providing comprehensive type definitions and IntelliSense support. Full type safety for XML parsing operations. TypeScript Examples
Choose your preferred package manager to install StAX-XML:
# npm - Most popular package managernpm install stax-xml
# yarn - Fast, reliable package manageryarn add stax-xml
# pnpm - Efficient disk space usagepnpm add stax-xml
# bun - Ultra-fast JavaScript runtimebun add stax-xml
# deno - Secure TypeScript runtimedeno add npm:stax-xmlESM-only package: StAX-XML is published as ESM-only. Use import { ... } from 'stax-xml'; require('stax-xml') is not supported.
Platform Requirements:
Get started with StAX-XML in seconds. Here’s how to parse XML with streaming support:
import { EventReader, XmlEventType } from 'stax-xml';
// XML content to parseconst xmlContent = '<bookstore><book id="1"><title>JavaScript Guide</title></book></bookstore>';
// Create ReadableStream for streaming XML parsingconst stream = new ReadableStream({ start(controller) { controller.enqueue(new TextEncoder().encode(xmlContent)); controller.close(); }});
// Parse XML asynchronously with event-driven approachasync function parseXml() { const parser = new EventReader(stream); for await (const event of parser) { if (event.type === XmlEventType.START_ELEMENT) { console.log(`Found element: ${event.name}`); } }}parseXml();→ More Advanced Examples | → API Documentation
Unlike traditional XML-to-JSON mappers, StAX-XML provides pull-based parsing that gives you complete control over XML processing: