A simple, typed XML helper for Node.js built on fast-xml-parser.
- Node.js >= 22
npm install @gibme/xml
# or
yarn add @gibme/xmlhttps://gibme-npm.github.io/xml/
Converts a JavaScript object to an XML string.
import XML from "@gibme/xml";
const obj = {
root: {
test: true,
text: "hello",
num: 42
}
};
const xml = XML.objToXML(obj);Parses an XML string or Buffer into a typed JavaScript object.
import XML from "@gibme/xml";
interface MyData {
root: {
test: boolean;
text: string;
num: number;
};
}
const data = await XML.parseXML<MyData>(xmlString);XML.ParserOptions— Configuration for the XML parserXML.BuilderOptions— Configuration for the XML builderXML.ValidatorOptions— Configuration for XML validation
These map directly to fast-xml-parser options.
MIT