Getting Started
StAX-XML is a high-performance, pull-based XML parser for JavaScript/TypeScript that works across all JavaScript runtimes.
Installation
Section titled “Installation”Install StAX-XML using your preferred package manager:
# npmnpm install stax-xml
# yarnyarn add stax-xml
# pnpmpnpm add stax-xml
# bunbun add stax-xml
# denodeno add npm:stax-xml
Platform Compatibility
Section titled “Platform Compatibility”StAX-XML uses only Web Standard APIs, making it compatible with:
- Node.js (v18+)
- Bun (any version)
- Deno (any version)
- Web Browsers (modern browsers)
- Edge Runtime (Vercel, Cloudflare Workers, etc.)
Core Concepts
Section titled “Core Concepts”StAX-XML provides two main parsing approaches:
Asynchronous Parsing (StaxXmlParser)
Section titled “Asynchronous Parsing (StaxXmlParser)”For memory-efficient processing of large XML files using streams:
import { StaxXmlParser } from 'stax-xml';
const parser = new StaxXmlParser(readableStream);for await (const event of parser) { // Process XML events}
Synchronous Parsing (StaxXmlParserSync)
Section titled “Synchronous Parsing (StaxXmlParserSync)”For high-performance parsing of smaller, in-memory XML strings:
import { StaxXmlParserSync } from 'stax-xml';
const parser = new StaxXmlParserSync(xmlString);for (const event of parser) { // Process XML events}
Next Steps
Section titled “Next Steps”- Quick Start Guide - Jump right in with practical examples
- Examples - See real-world usage patterns