Node Module to convert Memory structure to XML and vice versa
Pull request Compare This branch is 49 commits behind Inist-CNRS:master.
Latest commit c0c68a7 Dec 19, 2012 @touv touv Update README.md
Failed to load latest commit information.
examples add demonstrator Feb 23, 2012
lib made error throwing optional to maintain backward-compatibility Dec 17, 2012
test made error throwing optional to maintain backward-compatibility Dec 18, 2012
.gitignore debut des tests Nov 17, 2011
.travis.yml adding travis CI Mar 5, 2012
AUTHORS
LICENSE
README.md Update README.md Dec 19, 2012
index.js first test ok Nov 18, 2011
package.json

README.md

xml2json and json2xml for NodeJS

Build Status

It's native javascript implementation of a bidirectional converter between XML and JS data structure (aka JSON). You can convert any type of XML documents in an Javascript data structure. You can also do the reverse, converting a Javascript data structure in XML String. XML is still valid.

Contributors

Installation

With npm do:

$ npm install xml-mapping

Usage

var xm = require('xml-mapping');

var json = xm.load('<key>value</key>');
var xml  = xm.dump(json);

console.log(xml,json);
console.log(json);

Output:

<key>value</key> { key: { '$t': 'value' } }

Convention

The rules for converting XML to JSON are those used by Google in its GData protocol. More information here : http://code.google.com/apis/gdata/docs/json.html

Tests

Use nodeunit to run the tests.

$ npm install nodeunit
$ nodeunit test

API Documentation

load(String xml)

Transform a string with XML in Javascript data structure (JSON). Return Object.

dump(Object json)

Transform a Javascript data structure (JSON) in XML string. Return String.

tojson(String xml)

Alias of load.

toxml(Object json)

Alias of dump.

Also

License

MIT/X11