parseXmlStreamFromBytes

import { parseXmlStreamFromBytes } from "jsr:@ende/xml";

function

function parseXmlStreamFromBytes(source: AsyncIterable<Uint8Array>, callbacks: XmlEventCallbacks, options: ParseStreamOptions = [UNSUPPORTED]): Promise<void>

Parse XML from a byte stream with maximum throughput using direct callbacks.

This is a convenience wrapper around parseXmlStream that handles text decoding. For pre-decoded text streams, use parseXmlStream directly.

source: AsyncIterable<Uint8Array>

The async iterable of XML byte chunks to parse.

callbacks: XmlEventCallbacks

The event callbacks invoked during parsing.

options: ParseStreamOptions = [UNSUPPORTED]

Options for configuring the parser.

Returns

A promise that resolves when parsing is complete.

Example: Basic usage

import { parseXmlStreamFromBytes } from "@ende/xml/parse-stream";
import { assertEquals } from "@ende/assert";

const xml = new TextEncoder().encode("<root>Hello</root>");
const stream = ReadableStream.from([xml]);

let text = "";
await parseXmlStreamFromBytes(stream, {
  onText(t) { text += t; },
});

assertEquals(text, "Hello");

Source