Giter VIP home page Giter VIP logo

rapidx2j's Introduction

rapidx2j

Node.JS module for converting XML documents into JSON objects. It should be one of the fastest converters available. Uses RapidXML. Inspired by fast-feed.

Installation

npm install --save rapidx2j

Usage

x2j.parse(xml_string[, options][, callback]);

Sync

var x2j = require('rapidx2j');
var json = x2j.parse(xml_string);
console.log(json);

Sync with optional config object:

var x2j = require('rapidx2j');
var options = {
  empty_tag_value: null,
  parse_boolean_values: true,
  parse_int_numbers: true,
  parse_float_numbers: true,
  preserve_case: false,
  skip_parse_when_begins_with: ''  
};
var json = x2j.parse(xml_string, options);
console.log(json);

Async with callback

var x2j = require('rapidx2j');
var json = x2j.parse(xml_string, function(err, json) {
  if (!err)
    console.log(json);
});

Note that by default, rapidx2j will use 'true' as a value for empty XML tags; with config param 'empty_tag_value' one can set that to something else (i.e. to 'null' in this case). 'parse_boolean_values', 'parse_int_numbers' and 'parse_float_numbers' will or will not parse XML values which are bool/int/float numbers to appropriate java script types. 'preserve_case' will or will not preserve XML tag and attribute name case. 'skip_parse_when_begins_with' will not parse XML values which begin with a given string to appropriate java script types.

Supported Node versions

  • node 0.10.x
  • node 0.12.x
  • node 4.x
  • node 5.x
  • node 6.x

Contributors

License & copyright

Copyright (c) 2015 Damir Nedžibović

Use of this software is granted under the MIT or the Boost Software License, to be chosen freely by the user.

RapidXML is dual-licensed (MIT and Boost Software License, see LICENSE.rapidxml).

rapidx2j's People

Contributors

damirn avatar redsandro avatar nfnchris avatar

Watchers

Tuan Anh Tran avatar James Cloos avatar  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.