Skip to content

thlorenz/node-xml-mapping

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Node Module to convert Memory structure to XML and vice versa

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.8%
  • Shell 0.2%