Robust XML parser/streamer/builder for AI-generated and real-world XML. RXML focuses on resilience (lenient parsing when possible), JSON Schema–based coercion, efficient streaming, and clean stringification.
npm install @biubiupiu/rxmlRobust XML parser/streamer/builder for AI-generated and real-world XML. RXML focuses on resilience (lenient parsing when possible), JSON Schema–based coercion, efficient streaming, and clean stringification.
``bash`
pnpm add @ai-sdk-tool/rxmlor
npm i @ai-sdk-tool/rxmlor
yarn add @ai-sdk-tool/rxml
- Parse with JSON Schema coercion
`ts
import { parse } from "@ai-sdk-tool/rxml";
const schema = {
type: "object",
properties: { title: { type: "string" } },
};
const out = parse("
- Stream large XML
`ts
import { createReadStream } from "node:fs";
import { processXMLStream } from "@ai-sdk-tool/rxml";const stream = createReadStream("./large.xml", "utf8");
for await (const node of processXMLStream(stream)) {
// node is an RXMLNode or a comment string
}
`- Stringify objects to XML
`ts
import { stringify } from "@ai-sdk-tool/rxml";const xml = stringify("root", { title: "Hello" });
`More docs
See full documentation at
docs/rxml.md` (in the repository root).