@gibme/xml
v22.0.1
Published
A simple XML helper
Downloads
413
Readme
@gibme/xml
A simple, typed XML helper for Node.js built on fast-xml-parser.
Requirements
- Node.js >= 22
Installation
npm install @gibme/xml
# or
yarn add @gibme/xmlDocumentation
https://gibme-npm.github.io/xml/
API
XML.objToXML<Type>(obj, builderOptions?): string
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);XML.parseXML<Type>(xml, parserOptions?, validatorOptions?): Promise<Type>
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);Options Types
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.
License
MIT
