2.1.1 • Published 9 years ago

faketoe v2.1.1

Weekly downloads
50
License
-
Repository
github
Last release
9 years ago

faketoe Logo

XML to JSON converter

Build Status

Lead Maintainer: Nathan LaFreniere

Description

faketoe is a simple Node transformation stream for used to convert an XML stream to a JSON object. It is a thin wrapper around node-expat and supports the same interface and events as a node-expat object.

Usage

var Fs = require('fs');
var FakeToe = require('./lib');

var parser = FakeToe.createParser(function (error, result) {
    // `result` is:
    // {
    //     item: {
    //             name: '1',
    //         property: 'a',
    //            child: [
    //             [0] {
    //                     name: '2',
    //                 property: 'a',
    //                    child: [
    //                     [0] {
    //                             name: '3',
    //                         property: 'a'
    //                     },
    //                     [1] {
    //                         name: '4'
    //                     }
    //                 ]
    //             },
    //             [1] {
    //                 name: '5'
    //             }
    //         ],
    //          goblins: {
    //             goblin: [
    //                 [0] {
    //                     type: 'ear'
    //                 },
    //                 [1] {
    //                     type: 'nose'
    //                 },
    //                 [2] {
    //                     type: 'throat'
    //                 }
    //             ]
    //         },
    //                x: {
    //               y: [
    //                 [0] 'a',
    //                 [1] 'b',
    //                 [2] 'c'
    //             ]
    //         },
    //            extra: {
    //             extended: 'yes'
    //         },
    //                z: {
    //             verbose: 'no',
    //               $text: 'a'
    //         }
    //     }
    // }

});

parser.on('text', function (text) {

    console.log('text event: ' + text);
});

parser.on('endElement', function (name) {

    console.log('end element event: ' + name);
});

Fs.createReadStream(__dirname + '/test/test1.xml').pipe(parser);

Methods

####createParser(callback) creates an XML to JSON parser (stream). The callback function signature is function (error, result) where

  • error - internal error condition
  • result - the complete JSON object
2.1.1

9 years ago

2.1.0

9 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.0.0

10 years ago

0.1.2

10 years ago

0.1.1

11 years ago

0.1.0

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago