The code is all contained within the
x2js.js file, so you can include it directly
via a script tag. It will create
window.X2JS, which is a constructor that can be
used to create instances of the converter, providing an optional configuration object.
In a Node app,
require("x2js") will give you the constructor that you can use the same way.
Loading via AMD-capable loaders (e.g. require.js) is also supported and works equivalently.
xmldom package is a dependency but it is only used under Node, as in browsers the browser DOM is used.
var x2js = ;var document = x2js;console;var xml = x2js;console;
See the type definitions within
x2js.d.ts for information about what configuration options you can pass.
A set of QUnit test cases are part of the project and act as the primary usage examples.
karma start --single run to test with Chrome, Firefox and IE.
node_modules\.bin\qunit-cli all_tests.js to test with the Node runtime.
npm test to execute both sets of tests.
Travis CI uses
npm travistest to run tests using Firefox via Karma and Node.
Contributions are welcome! To ensure speedy merges, please:
- base any pull requests on the development branch.
- ensure that the code passes ESLint validation with the included ruleset.