Convert XML to JSON - Fast & Simple
npm install simple-xml-to-json


xmlToConvert \customConverter \customConverter is usedxmlToConvert \Code Example:
``javascript
const {convertXML, createAST} = require("simple-xml-to-json")
const myJson = convertXML(myXMLString)
const myYaml = convertXML(myXMLString, yamlConverter)
const myAst = createAST(myXMLString)
``
---
in your terminal and see what happens.
2. There's the xmlToJson.js` file for convenience. Just pass in the XML as a String._Take these results with a grain of salt._\
According to a __simple__ benchmark test I performed in __April 2024__ with a random XML. _YMMV_.
!Benchmark Chart
* The chart results __may be__ outdated. Run the test yourself
so you cannot by default have an attribute with that name and free text as the content of the element or have nested elements as children.
If you need to, you can write your own converter from the AST created by the parser, and pass it as a 2nd parameter after the xml string