-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
129 lines (129 loc) · 12.6 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
{
"name": "xml2js",
"description": "Simple XML to JavaScript object converter.",
"keywords": [
"xml",
"json"
],
"homepage": "https://github.com/Leonidas-from-XIV/node-xml2js",
"version": "0.2.8",
"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"
},
{
"name": "Salsita Software",
"url": "http://www.salsitasoft.com/"
},
{
"name": "Mike Schilling",
"email": "mike@emotive.com",
"url": "http://www.emotive.com/"
},
{
"name": "Jackson Tian",
"email": "shyvo1987@gmail.com",
"url": "http://weibo.com/shyvo"
},
{
"name": "Mikhail Zyatin",
"email": "mikhail.zyatin@gmail.com",
"url": "https://github.com/Sitin"
},
{
"name": "Chris Tavares",
"email": "ctavares@microsoft.com",
"url": "https://github.com/christav"
},
{
"name": "Frank Xu",
"email": "yyfrankyy@gmail.com",
"url": "http://f2e.us/"
}
],
"main": "./lib/xml2js",
"directories": {
"lib": "./lib"
},
"scripts": {
"test": "zap"
},
"repository": {
"type": "git",
"url": "https://github.com/Leonidas-from-XIV/node-xml2js.git"
},
"dependencies": {
"sax": "0.5.x"
},
"devDependencies": {
"coffee-script": ">=1.6.3",
"zap": ">=0.2.5",
"docco": ">=0.6.2"
},
"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\nNo extensive tutorials required because you are a smart developer! The task of\nparsing XML should be an easy one, so let's make it so! Here's some examples.\n\nShoot-and-forget usage\n----------------------\n\nYou want to parse XML as simple and easy as possible? It's dangerous to go\nalone, take this:\n\n```javascript\nvar parseString = require('xml2js').parseString;\nvar xml = \"<root>Hello xml2js!</root>\"\nparseString(xml, function (err, result) {\n console.dir(result);\n});\n```\n\nCan't get easier than this, right? This works starting with `xml2js` 0.2.3.\nWith CoffeeScript it looks like this:\n\n```coffeescript\nparseString = require('xml2js').parseString\nxml = \"<root>Hello xml2js!</root>\"\nparseString xml, (err, result) ->\n console.dir result\n```\n\nIf you need some special options, fear not, `xml2js` supports a number of\noptions (see below), you can specify these as second argument:\n\n```javascript\nparseString(xml, {trim: true}, function (err, result) {\n});\n```\n\nSimple as pie usage\n-------------------\n\nThat's right, if you have been using xml-simple or a home-grown\nwrapper, this is was added in 0.1.11 just 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!\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\nBut what happens if you forget the `new` keyword to create a new `Parser`? In\nthe middle of a nightly coding session, it might get lost, after all. Worry\nnot, we got you covered! Starting with 0.2.8 you can also leave it out, in\nwhich case `xml2js` will helpfully add it for you, no bad surprises and\ninexplicable bugs!\n\n\"Traditional\" usage\n-------------------\n\nAlternatively you can still use the traditional `addListener` variant that was\nsupported since forever:\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\nIf you want to parse multiple files, you have multiple possibilites:\n\n * You can create one `xml2js.Parser` per file. That's the recommended one\n and is promised to always *just work*.\n * You can call `reset()` on your parser object.\n * You can hope everything goes well anyway. This behaviour is not\n guaranteed work always, if ever. Use option #1 if possible. Thanks!\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 * `attrkey` (default: `$`): Prefix that is used to access the attributes.\n Version 0.1 default was `@`.\n * `charkey` (default: `_`): Prefix that is used to access the character\n content. Version 0.1 default was `#`.\n * `explicitCharkey` (default: `false`)\n * `trim` (default: `false`): Trim the whitespace at the beginning and end of\n text nodes.\n * `normalizeTags` (default: `false`): Normalize all tag names to lowercase.\n * `normalize` (default: `false`): Trim whitespaces inside text nodes.\n * `explicitRoot` (default: `true`): 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: `true`): 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 * `validator` (default `null`): You can specify a callable that validates\n the resulting structure somehow, however you want. See unit tests\n for an example.\n * `xmlns` (default `false`): Give each element a field usually called '$ns'\n (the first character is the same as attrkey) that contains its local name\n and namespace URI.\n * `explicitChildren` (default `false`): Put child elements to separate\n property. Doesn't work with `mergeAttrs = true`. If element has no children\n then \"children\" won't be created. Added in 0.2.5.\n * `childkey` (default `$$`): Prefix that is used to access child elements if\n `explicitChildren` is set to `true`. Added in 0.2.5.\n * `charsAsChildren` (default `false`): Determines whether chars should be\n considered children if `explicitChildren` is on. Added in 0.2.5.\n * `async` (default `false`): Should the callbacks be async? This *might* be\n an incompatible change if your code depends on sync execution of callbacks.\n xml2js 0.3 might change this default, so the recommendation is to not\n depend on sync execution anyway. Added in 0.2.6.\n * `strict` (default `true`): Set sax-js to strict or non-strict parsing mode.\n Defaults to `true` which is *highly* recommended, since parsing HTML which\n is not well-formed XML might yield just about anything. Added in 0.2.7.\n\nUpdating to new version\n=======================\n\nVersion 0.2 changed the default parsing settings, but version 0.1.14 introduced\nthe default settings for version 0.2, so these settings can be tried before the\nmigration.\n\n```javascript\nvar xml2js = require('xml2js');\nvar parser = new xml2js.Parser(xml2js.defaults[\"0.2\"]);\n```\n\nTo get the 0.1 defaults in version 0.2 you can just use\n`xml2js.defaults[\"0.1\"]` in the same place. This provides you with enough time\nto migrate to the saner way of parsing in xml2js 0.2. We try to make the\nmigration as simple and gentle as possible, but some breakage cannot be\navoided.\n\nSo, what exactly did change and why? In 0.2 we changed some defaults to parse\nthe XML in a more universal and sane way. So we disabled `normalize` and `trim`\nso xml2js does not cut out any text content. You can reenable this at will of\ncourse. A more important change is that we return the root tag in the resulting\nJavaScript structure via the `explicitRoot` setting, so you need to access the\nfirst element. This is useful for anybody who wants to know what the root node\nis and preserves more information. The last major change was to enable\n`explicitArray`, so everytime it is possible that one might embed more than one\nsub-tag into a tag, xml2js >= 0.2 returns an array even if the array just\nincludes one element. This is useful when dealing with APIs that return\nvariable amounts of subtags.\n\nRunning tests, development\n==========================\n\n[![Build Status](https://secure.travis-ci.org/Leonidas-from-XIV/node-xml2js.png?branch=master)](https://travis-ci.org/Leonidas-from-XIV/node-xml2js)\n\nThe development requirements are handled by npm, you just need to install them.\nWe also have a number of unit tests, they can be run using `npm test` directly\nfrom the project root. This runs zap to discover all the tests and execute\nthem.\n\nIf you like to contribute, keep in mind that xml2js is written in CoffeeScript,\nso don't develop on the JavaScript files that are checked into the repository\nfor convenience reasons. Also, please write some unit test to check your\nbehaviour and if it is some user-facing thing, add some documentation to this\nREADME, so people will know it exists. Thanks in advance!\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/Leonidas-from-XIV/node-xml2js/issues"
},
"_id": "xml2js@0.2.8",
"dist": {
"shasum": "e835f5bd2dfddde5e627953bbe9a60144abb9bb0"
},
"_from": "xml2js@0.2.8",
"_resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.2.8.tgz"
}