Giter Club home page Giter Club logo

x2js's Introduction

x2js

This is a library that converts between XML and JavaScript objects. The conversion is not necessarily lossless but it is very convenient.

npm version

master development
Build Status Build Status

Integration

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.

The xmldom package is a dependency but it is only used under Node, as in browsers the browser DOM is used.

Quick start

var x2js = new X2JS();
var document = x2js.xml2js(xml);

console.log(document.MyRootElement.ElementX[1].toString());

var xml = x2js.js2xml(document);
console.log(xml);

See the type definitions within x2js.d.ts for information about what configuration options you can pass.

Automated tests

A set of QUnit test cases are part of the project and act as the primary usage examples.

Run karma start --single run to test with Chrome, Firefox and IE. Run node_modules\.bin\qunit-cli all_tests.js to test with the Node runtime. Run npm test to execute both sets of tests.

Travis CI uses npm travistest to run tests using Firefox via Karma and Node.

Contributing

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.

x2js's People

Contributors

abdolence avatar audarth avatar charlesvg avatar ezhukovskiy avatar giuppe avatar gulping avatar itjope avatar maxouhell avatar opoudjis avatar rtrompier avatar sandersaares avatar seth-niimi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.