Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Node Module to convert Memory structure to XML and vice versa

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 AUTHORS
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 index.js
Octocat-spinner-32 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

Something went wrong with that request. Please try again.