blob: 3946eff98f15b4f0a8bf8785f909fc26c388b034 [file] [log] [blame]
{
"name": "xml2js",
"description": "Simple XML to JavaScript object converter.",
"keywords": [
"xml",
"json"
],
"homepage": "https://github.com/Leonidas-from-XIV/node-xml2js",
"version": "0.1.13",
"author": {
"name": "Marek Kubica",
"email": "marek@xivilization.net",
"url": "http://xivilization.net"
},
"contributors": [
{
"name": "maqr",
"email": "maqr.lollerskates@gmail.com",
"url": "https://github.com/maqr"
},
{
"name": "Ben Weaver",
"url": "http://benweaver.com/"
},
{
"name": "Jae Kwon",
"url": "https://github.com/jaekwon"
},
{
"name": "Jim Robert"
},
{
"name": "Ștefan Rusu",
"url": "http://www.saltwaterc.eu/"
},
{
"name": "Carter Cole",
"email": "carter.cole@cartercole.com",
"url": "http://cartercole.com/"
},
{
"name": "Kurt Raschke",
"email": "kurt@kurtraschke.com",
"url": "http://www.kurtraschke.com/"
},
{
"name": "Contra",
"email": "contra@australia.edu",
"url": "https://github.com/Contra"
},
{
"name": "Marcelo Diniz",
"email": "marudiniz@gmail.com",
"url": "https://github.com/mdiniz"
},
{
"name": "Michael Hart",
"url": "https://github.com/mhart"
},
{
"name": "Zachary Scott",
"email": "zachary@zacharyscott.net",
"url": "http://zacharyscott.net/"
},
{
"name": "Raoul Millais",
"url": "https://github.com/raoulmillais"
}
],
"main": "./lib/xml2js",
"directories": {
"lib": "./lib"
},
"repository": {
"type": "git",
"url": "https://github.com/Leonidas-from-XIV/node-xml2js.git"
},
"dependencies": {
"sax": ">=0.1.1"
},
"devDependencies": {
"coffee-script": ">=1.0.1",
"zap": ">=0.2.3"
},
"readme": "node-xml2js\n===========\n\nEver had the urge to parse XML? And wanted to access the data in some sane,\neasy way? Don't want to compile a C parser, for whatever reason? Then xml2js is\nwhat you're looking for!\n\nDescription\n===========\n\nSimple XML to JavaScript object converter. Uses\n[sax-js](https://github.com/isaacs/sax-js/).\n\nNote: If you're looking for a full DOM parser, you probably want\n[JSDom](https://github.com/tmpvar/jsdom).\n\nInstallation\n============\n\nSimplest way to install `xml2js` is to use [npm](http://npmjs.org), just `npm\ninstall xml2js` which will download xml2js and all dependencies.\n\nUsage\n=====\n\nThis will have to do, unless you're looking for some fancy extensive\ndocumentation. If you're looking for every single option and usage, see the\nunit tests.\n\nSimple as pie usage\n-------------------\n\nThe simplest way to use it, is to use the optional callback interface added in\n0.1.11. That's right, if you have been using xml-simple or a home-grown\nwrapper, this is for you:\n\n```javascript\nvar fs = require('fs'),\n xml2js = require('xml2js');\n\nvar parser = new xml2js.Parser();\nfs.readFile(__dirname + '/foo.xml', function(err, data) {\n parser.parseString(data, function (err, result) {\n console.dir(result);\n console.log('Done');\n });\n});\n```\n\nLook ma, no event listeners! Alternatively you can still use the traditional\n`addListener` variant:\n\n```javascript\nvar fs = require('fs'),\n xml2js = require('xml2js');\n\nvar parser = new xml2js.Parser();\nparser.addListener('end', function(result) {\n console.dir(result);\n console.log('Done.');\n});\nfs.readFile(__dirname + '/foo.xml', function(err, data) {\n parser.parseString(data);\n});\n```\n\nYou can also use xml2js from\n[CoffeeScript](http://jashkenas.github.com/coffee-script/), further reducing\nthe clutter:\n\n```coffeescript\nfs = require 'fs',\nxml2js = require 'xml2js'\n\nparser = new xml2js.Parser()\nfs.readFile __dirname + '/foo.xml', (err, data) ->\n parser.parseString data, (err, result) ->\n console.dir result\n console.log 'Done.'\n```\n\nSo you wanna some JSON?\n-----------------------\n\nJust wrap the `result` object in a call to `JSON.stringify` like this\n`JSON.stringify(result)`. You get a string containing the JSON representation\nof the parsed object that you can feed to JSON-hungry consumers.\n\nDisplaying results\n------------------\n\nYou might wonder why, using `console.dir` or `console.log` the output at some\nlevel is only `[Object]`. Don't worry, this is not because xml2js got lazy.\nThat's because Node uses `util.inspect` to convert the object into strings and\nthat function stops after `depth=2` which is a bit low for most XML.\n\nTo display the whole deal, you can use `console.log(util.inspect(result, false,\nnull))`, which displays the whole result.\n\nSo much for that, but what if you use\n[eyes](https://github.com/cloudhead/eyes.js) for nice colored output and it\ntruncates the output with `…`? Don't fear, there's also a solution for that,\nyou just need to increase the `maxLength` limit by creating a custom inspector\n`var inspect = require('eyes').inspector({maxLength: false})` and then you can\neasily `inspect(result)`.\n\nOptions\n=======\n\nApart from the default settings, there is a number of options that can be\nspecified for the parser. Options are specified by ``new Parser({optionName:\nvalue})``. Possible options are:\n\n * `explicitCharkey` (default: `false`)\n * `trim` (default: `true`): Trim the whitespace at the beginning and end of\n text nodes.\n * `normalize` (default: `true`): Trim whitespaces inside text nodes.\n * `explicitRoot` (default: `false`): Set this if you want to get the root\n node in the resulting object.\n * `emptyTag` (default: `undefined`): what will the value of empty nodes be.\n Default is `{}`.\n * `explicitArray` (default: `false`): Always put child nodes in an array if\n true; otherwise an array is created only if there is more than one.\n * `ignoreAttrs` (default: `false`): Ignore all XML attributes and only create\n text nodes.\n * `mergeAttrs` (default: `false`): Merge attributes and child elements as\n properties of the parent, instead of keying attributes off a child\n attribute object. This option is ignored if `ignoreAttrs` is `false`.\n\nThese default settings are for backward-compatibility (and might change in the\nfuture). For the most 'clean' parsing, you should disable `normalize` and\n`trimming` and enable `explicitRoot`.\n\nRunning tests, development\n==========================\n\nThe development requirements are handled by npm, you just need to install\nthem. We also have a number of unit tests, they can be run using `zap`\ndirectly from the project root.\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/Leonidas-from-XIV/node-xml2js/issues"
},
"_id": "xml2js@0.1.13",
"_from": "xml2js@0.1.13"
}