xml2js 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec_status +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +41 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/xml2js.rb +5 -0
- data/lib/xml2js/node_modules/sax/LICENSE +41 -0
- data/lib/xml2js/node_modules/sax/README.md +225 -0
- data/lib/xml2js/node_modules/sax/lib/sax.js +1565 -0
- data/lib/xml2js/node_modules/sax/package.json +61 -0
- data/lib/xml2js/node_modules/xml2js/LICENSE +19 -0
- data/lib/xml2js/node_modules/xml2js/README.md +406 -0
- data/lib/xml2js/node_modules/xml2js/lib/bom.js +12 -0
- data/lib/xml2js/node_modules/xml2js/lib/builder.js +127 -0
- data/lib/xml2js/node_modules/xml2js/lib/defaults.js +72 -0
- data/lib/xml2js/node_modules/xml2js/lib/parser.js +357 -0
- data/lib/xml2js/node_modules/xml2js/lib/processors.js +34 -0
- data/lib/xml2js/node_modules/xml2js/lib/xml2js.js +37 -0
- data/lib/xml2js/node_modules/xml2js/package.json +280 -0
- data/lib/xml2js/node_modules/xmlbuilder/.npmignore +5 -0
- data/lib/xml2js/node_modules/xmlbuilder/CHANGELOG.md +423 -0
- data/lib/xml2js/node_modules/xmlbuilder/LICENSE +21 -0
- data/lib/xml2js/node_modules/xmlbuilder/README.md +85 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/Utility.js +73 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLAttribute.js +31 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLCData.js +32 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLComment.js +32 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDTDAttList.js +50 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDTDElement.js +35 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDTDEntity.js +56 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDTDNotation.js +37 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDeclaration.js +40 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDocType.js +107 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDocument.js +48 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDocumentCB.js +402 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLElement.js +111 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLNode.js +432 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js +35 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLRaw.js +32 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLStreamWriter.js +279 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLStringWriter.js +334 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLStringifier.js +163 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLText.js +32 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/XMLWriterBase.js +90 -0
- data/lib/xml2js/node_modules/xmlbuilder/lib/index.js +53 -0
- data/lib/xml2js/node_modules/xmlbuilder/package.json +65 -0
- data/lib/xml2js/package-lock.json +25 -0
- data/lib/xml2js/parser.js +33 -0
- data/lib/xml2js/parser.rb +31 -0
- data/lib/xml2js/version.rb +3 -0
- data/xml2js.gemspec +30 -0
- metadata +154 -0
@@ -0,0 +1,163 @@
|
|
1
|
+
// Generated by CoffeeScript 1.12.7
|
2
|
+
(function() {
|
3
|
+
var XMLStringifier,
|
4
|
+
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
5
|
+
hasProp = {}.hasOwnProperty;
|
6
|
+
|
7
|
+
module.exports = XMLStringifier = (function() {
|
8
|
+
function XMLStringifier(options) {
|
9
|
+
this.assertLegalChar = bind(this.assertLegalChar, this);
|
10
|
+
var key, ref, value;
|
11
|
+
options || (options = {});
|
12
|
+
this.noDoubleEncoding = options.noDoubleEncoding;
|
13
|
+
ref = options.stringify || {};
|
14
|
+
for (key in ref) {
|
15
|
+
if (!hasProp.call(ref, key)) continue;
|
16
|
+
value = ref[key];
|
17
|
+
this[key] = value;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
XMLStringifier.prototype.eleName = function(val) {
|
22
|
+
val = '' + val || '';
|
23
|
+
return this.assertLegalChar(val);
|
24
|
+
};
|
25
|
+
|
26
|
+
XMLStringifier.prototype.eleText = function(val) {
|
27
|
+
val = '' + val || '';
|
28
|
+
return this.assertLegalChar(this.elEscape(val));
|
29
|
+
};
|
30
|
+
|
31
|
+
XMLStringifier.prototype.cdata = function(val) {
|
32
|
+
val = '' + val || '';
|
33
|
+
val = val.replace(']]>', ']]]]><![CDATA[>');
|
34
|
+
return this.assertLegalChar(val);
|
35
|
+
};
|
36
|
+
|
37
|
+
XMLStringifier.prototype.comment = function(val) {
|
38
|
+
val = '' + val || '';
|
39
|
+
if (val.match(/--/)) {
|
40
|
+
throw new Error("Comment text cannot contain double-hypen: " + val);
|
41
|
+
}
|
42
|
+
return this.assertLegalChar(val);
|
43
|
+
};
|
44
|
+
|
45
|
+
XMLStringifier.prototype.raw = function(val) {
|
46
|
+
return '' + val || '';
|
47
|
+
};
|
48
|
+
|
49
|
+
XMLStringifier.prototype.attName = function(val) {
|
50
|
+
return val = '' + val || '';
|
51
|
+
};
|
52
|
+
|
53
|
+
XMLStringifier.prototype.attValue = function(val) {
|
54
|
+
val = '' + val || '';
|
55
|
+
return this.attEscape(val);
|
56
|
+
};
|
57
|
+
|
58
|
+
XMLStringifier.prototype.insTarget = function(val) {
|
59
|
+
return '' + val || '';
|
60
|
+
};
|
61
|
+
|
62
|
+
XMLStringifier.prototype.insValue = function(val) {
|
63
|
+
val = '' + val || '';
|
64
|
+
if (val.match(/\?>/)) {
|
65
|
+
throw new Error("Invalid processing instruction value: " + val);
|
66
|
+
}
|
67
|
+
return val;
|
68
|
+
};
|
69
|
+
|
70
|
+
XMLStringifier.prototype.xmlVersion = function(val) {
|
71
|
+
val = '' + val || '';
|
72
|
+
if (!val.match(/1\.[0-9]+/)) {
|
73
|
+
throw new Error("Invalid version number: " + val);
|
74
|
+
}
|
75
|
+
return val;
|
76
|
+
};
|
77
|
+
|
78
|
+
XMLStringifier.prototype.xmlEncoding = function(val) {
|
79
|
+
val = '' + val || '';
|
80
|
+
if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) {
|
81
|
+
throw new Error("Invalid encoding: " + val);
|
82
|
+
}
|
83
|
+
return val;
|
84
|
+
};
|
85
|
+
|
86
|
+
XMLStringifier.prototype.xmlStandalone = function(val) {
|
87
|
+
if (val) {
|
88
|
+
return "yes";
|
89
|
+
} else {
|
90
|
+
return "no";
|
91
|
+
}
|
92
|
+
};
|
93
|
+
|
94
|
+
XMLStringifier.prototype.dtdPubID = function(val) {
|
95
|
+
return '' + val || '';
|
96
|
+
};
|
97
|
+
|
98
|
+
XMLStringifier.prototype.dtdSysID = function(val) {
|
99
|
+
return '' + val || '';
|
100
|
+
};
|
101
|
+
|
102
|
+
XMLStringifier.prototype.dtdElementValue = function(val) {
|
103
|
+
return '' + val || '';
|
104
|
+
};
|
105
|
+
|
106
|
+
XMLStringifier.prototype.dtdAttType = function(val) {
|
107
|
+
return '' + val || '';
|
108
|
+
};
|
109
|
+
|
110
|
+
XMLStringifier.prototype.dtdAttDefault = function(val) {
|
111
|
+
if (val != null) {
|
112
|
+
return '' + val || '';
|
113
|
+
} else {
|
114
|
+
return val;
|
115
|
+
}
|
116
|
+
};
|
117
|
+
|
118
|
+
XMLStringifier.prototype.dtdEntityValue = function(val) {
|
119
|
+
return '' + val || '';
|
120
|
+
};
|
121
|
+
|
122
|
+
XMLStringifier.prototype.dtdNData = function(val) {
|
123
|
+
return '' + val || '';
|
124
|
+
};
|
125
|
+
|
126
|
+
XMLStringifier.prototype.convertAttKey = '@';
|
127
|
+
|
128
|
+
XMLStringifier.prototype.convertPIKey = '?';
|
129
|
+
|
130
|
+
XMLStringifier.prototype.convertTextKey = '#text';
|
131
|
+
|
132
|
+
XMLStringifier.prototype.convertCDataKey = '#cdata';
|
133
|
+
|
134
|
+
XMLStringifier.prototype.convertCommentKey = '#comment';
|
135
|
+
|
136
|
+
XMLStringifier.prototype.convertRawKey = '#raw';
|
137
|
+
|
138
|
+
XMLStringifier.prototype.assertLegalChar = function(str) {
|
139
|
+
var res;
|
140
|
+
res = str.match(/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/);
|
141
|
+
if (res) {
|
142
|
+
throw new Error("Invalid character in string: " + str + " at index " + res.index);
|
143
|
+
}
|
144
|
+
return str;
|
145
|
+
};
|
146
|
+
|
147
|
+
XMLStringifier.prototype.elEscape = function(str) {
|
148
|
+
var ampregex;
|
149
|
+
ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
|
150
|
+
return str.replace(ampregex, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\r/g, '
');
|
151
|
+
};
|
152
|
+
|
153
|
+
XMLStringifier.prototype.attEscape = function(str) {
|
154
|
+
var ampregex;
|
155
|
+
ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
|
156
|
+
return str.replace(ampregex, '&').replace(/</g, '<').replace(/"/g, '"').replace(/\t/g, '	').replace(/\n/g, '
').replace(/\r/g, '
');
|
157
|
+
};
|
158
|
+
|
159
|
+
return XMLStringifier;
|
160
|
+
|
161
|
+
})();
|
162
|
+
|
163
|
+
}).call(this);
|
@@ -0,0 +1,32 @@
|
|
1
|
+
// Generated by CoffeeScript 1.12.7
|
2
|
+
(function() {
|
3
|
+
var XMLNode, XMLText,
|
4
|
+
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
5
|
+
hasProp = {}.hasOwnProperty;
|
6
|
+
|
7
|
+
XMLNode = require('./XMLNode');
|
8
|
+
|
9
|
+
module.exports = XMLText = (function(superClass) {
|
10
|
+
extend(XMLText, superClass);
|
11
|
+
|
12
|
+
function XMLText(parent, text) {
|
13
|
+
XMLText.__super__.constructor.call(this, parent);
|
14
|
+
if (text == null) {
|
15
|
+
throw new Error("Missing element text");
|
16
|
+
}
|
17
|
+
this.value = this.stringify.eleText(text);
|
18
|
+
}
|
19
|
+
|
20
|
+
XMLText.prototype.clone = function() {
|
21
|
+
return Object.create(this);
|
22
|
+
};
|
23
|
+
|
24
|
+
XMLText.prototype.toString = function(options) {
|
25
|
+
return this.options.writer.set(options).text(this);
|
26
|
+
};
|
27
|
+
|
28
|
+
return XMLText;
|
29
|
+
|
30
|
+
})(XMLNode);
|
31
|
+
|
32
|
+
}).call(this);
|
@@ -0,0 +1,90 @@
|
|
1
|
+
// Generated by CoffeeScript 1.12.7
|
2
|
+
(function() {
|
3
|
+
var XMLWriterBase,
|
4
|
+
hasProp = {}.hasOwnProperty;
|
5
|
+
|
6
|
+
module.exports = XMLWriterBase = (function() {
|
7
|
+
function XMLWriterBase(options) {
|
8
|
+
var key, ref, ref1, ref2, ref3, ref4, ref5, ref6, value;
|
9
|
+
options || (options = {});
|
10
|
+
this.pretty = options.pretty || false;
|
11
|
+
this.allowEmpty = (ref = options.allowEmpty) != null ? ref : false;
|
12
|
+
if (this.pretty) {
|
13
|
+
this.indent = (ref1 = options.indent) != null ? ref1 : ' ';
|
14
|
+
this.newline = (ref2 = options.newline) != null ? ref2 : '\n';
|
15
|
+
this.offset = (ref3 = options.offset) != null ? ref3 : 0;
|
16
|
+
this.dontprettytextnodes = (ref4 = options.dontprettytextnodes) != null ? ref4 : 0;
|
17
|
+
} else {
|
18
|
+
this.indent = '';
|
19
|
+
this.newline = '';
|
20
|
+
this.offset = 0;
|
21
|
+
this.dontprettytextnodes = 0;
|
22
|
+
}
|
23
|
+
this.spacebeforeslash = (ref5 = options.spacebeforeslash) != null ? ref5 : '';
|
24
|
+
if (this.spacebeforeslash === true) {
|
25
|
+
this.spacebeforeslash = ' ';
|
26
|
+
}
|
27
|
+
this.newlinedefault = this.newline;
|
28
|
+
this.prettydefault = this.pretty;
|
29
|
+
ref6 = options.writer || {};
|
30
|
+
for (key in ref6) {
|
31
|
+
if (!hasProp.call(ref6, key)) continue;
|
32
|
+
value = ref6[key];
|
33
|
+
this[key] = value;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
XMLWriterBase.prototype.set = function(options) {
|
38
|
+
var key, ref, value;
|
39
|
+
options || (options = {});
|
40
|
+
if ("pretty" in options) {
|
41
|
+
this.pretty = options.pretty;
|
42
|
+
}
|
43
|
+
if ("allowEmpty" in options) {
|
44
|
+
this.allowEmpty = options.allowEmpty;
|
45
|
+
}
|
46
|
+
if (this.pretty) {
|
47
|
+
this.indent = "indent" in options ? options.indent : ' ';
|
48
|
+
this.newline = "newline" in options ? options.newline : '\n';
|
49
|
+
this.offset = "offset" in options ? options.offset : 0;
|
50
|
+
this.dontprettytextnodes = "dontprettytextnodes" in options ? options.dontprettytextnodes : 0;
|
51
|
+
} else {
|
52
|
+
this.indent = '';
|
53
|
+
this.newline = '';
|
54
|
+
this.offset = 0;
|
55
|
+
this.dontprettytextnodes = 0;
|
56
|
+
}
|
57
|
+
this.spacebeforeslash = "spacebeforeslash" in options ? options.spacebeforeslash : '';
|
58
|
+
if (this.spacebeforeslash === true) {
|
59
|
+
this.spacebeforeslash = ' ';
|
60
|
+
}
|
61
|
+
this.newlinedefault = this.newline;
|
62
|
+
this.prettydefault = this.pretty;
|
63
|
+
ref = options.writer || {};
|
64
|
+
for (key in ref) {
|
65
|
+
if (!hasProp.call(ref, key)) continue;
|
66
|
+
value = ref[key];
|
67
|
+
this[key] = value;
|
68
|
+
}
|
69
|
+
return this;
|
70
|
+
};
|
71
|
+
|
72
|
+
XMLWriterBase.prototype.space = function(level) {
|
73
|
+
var indent;
|
74
|
+
if (this.pretty) {
|
75
|
+
indent = (level || 0) + this.offset + 1;
|
76
|
+
if (indent > 0) {
|
77
|
+
return new Array(indent).join(this.indent);
|
78
|
+
} else {
|
79
|
+
return '';
|
80
|
+
}
|
81
|
+
} else {
|
82
|
+
return '';
|
83
|
+
}
|
84
|
+
};
|
85
|
+
|
86
|
+
return XMLWriterBase;
|
87
|
+
|
88
|
+
})();
|
89
|
+
|
90
|
+
}).call(this);
|
@@ -0,0 +1,53 @@
|
|
1
|
+
// Generated by CoffeeScript 1.12.7
|
2
|
+
(function() {
|
3
|
+
var XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
|
4
|
+
|
5
|
+
ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction;
|
6
|
+
|
7
|
+
XMLDocument = require('./XMLDocument');
|
8
|
+
|
9
|
+
XMLDocumentCB = require('./XMLDocumentCB');
|
10
|
+
|
11
|
+
XMLStringWriter = require('./XMLStringWriter');
|
12
|
+
|
13
|
+
XMLStreamWriter = require('./XMLStreamWriter');
|
14
|
+
|
15
|
+
module.exports.create = function(name, xmldec, doctype, options) {
|
16
|
+
var doc, root;
|
17
|
+
if (name == null) {
|
18
|
+
throw new Error("Root element needs a name");
|
19
|
+
}
|
20
|
+
options = assign({}, xmldec, doctype, options);
|
21
|
+
doc = new XMLDocument(options);
|
22
|
+
root = doc.element(name);
|
23
|
+
if (!options.headless) {
|
24
|
+
doc.declaration(options);
|
25
|
+
if ((options.pubID != null) || (options.sysID != null)) {
|
26
|
+
doc.doctype(options);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
return root;
|
30
|
+
};
|
31
|
+
|
32
|
+
module.exports.begin = function(options, onData, onEnd) {
|
33
|
+
var ref1;
|
34
|
+
if (isFunction(options)) {
|
35
|
+
ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
|
36
|
+
options = {};
|
37
|
+
}
|
38
|
+
if (onData) {
|
39
|
+
return new XMLDocumentCB(options, onData, onEnd);
|
40
|
+
} else {
|
41
|
+
return new XMLDocument(options);
|
42
|
+
}
|
43
|
+
};
|
44
|
+
|
45
|
+
module.exports.stringWriter = function(options) {
|
46
|
+
return new XMLStringWriter(options);
|
47
|
+
};
|
48
|
+
|
49
|
+
module.exports.streamWriter = function(stream, options) {
|
50
|
+
return new XMLStreamWriter(stream, options);
|
51
|
+
};
|
52
|
+
|
53
|
+
}).call(this);
|
@@ -0,0 +1,65 @@
|
|
1
|
+
{
|
2
|
+
"_from": "xmlbuilder@~9.0.1",
|
3
|
+
"_id": "xmlbuilder@9.0.7",
|
4
|
+
"_inBundle": false,
|
5
|
+
"_integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=",
|
6
|
+
"_location": "/xmlbuilder",
|
7
|
+
"_phantomChildren": {},
|
8
|
+
"_requested": {
|
9
|
+
"type": "range",
|
10
|
+
"registry": true,
|
11
|
+
"raw": "xmlbuilder@~9.0.1",
|
12
|
+
"name": "xmlbuilder",
|
13
|
+
"escapedName": "xmlbuilder",
|
14
|
+
"rawSpec": "~9.0.1",
|
15
|
+
"saveSpec": null,
|
16
|
+
"fetchSpec": "~9.0.1"
|
17
|
+
},
|
18
|
+
"_requiredBy": [
|
19
|
+
"/xml2js"
|
20
|
+
],
|
21
|
+
"_resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
|
22
|
+
"_shasum": "132ee63d2ec5565c557e20f4c22df9aca686b10d",
|
23
|
+
"_spec": "xmlbuilder@~9.0.1",
|
24
|
+
"_where": "/mnt/c/Users/neene/projects/rubyprojects/xml2js/lib/xml2js/node_modules/xml2js",
|
25
|
+
"author": {
|
26
|
+
"name": "Ozgur Ozcitak",
|
27
|
+
"email": "oozcitak@gmail.com"
|
28
|
+
},
|
29
|
+
"bugs": {
|
30
|
+
"url": "http://github.com/oozcitak/xmlbuilder-js/issues"
|
31
|
+
},
|
32
|
+
"bundleDependencies": false,
|
33
|
+
"contributors": [],
|
34
|
+
"dependencies": {},
|
35
|
+
"deprecated": false,
|
36
|
+
"description": "An XML builder for node.js",
|
37
|
+
"devDependencies": {
|
38
|
+
"coffee-coverage": "2.*",
|
39
|
+
"coffeescript": "1.*",
|
40
|
+
"coveralls": "*",
|
41
|
+
"istanbul": "*",
|
42
|
+
"mocha": "*"
|
43
|
+
},
|
44
|
+
"engines": {
|
45
|
+
"node": ">=4.0"
|
46
|
+
},
|
47
|
+
"homepage": "http://github.com/oozcitak/xmlbuilder-js",
|
48
|
+
"keywords": [
|
49
|
+
"xml",
|
50
|
+
"xmlbuilder"
|
51
|
+
],
|
52
|
+
"license": "MIT",
|
53
|
+
"main": "./lib/index",
|
54
|
+
"name": "xmlbuilder",
|
55
|
+
"repository": {
|
56
|
+
"type": "git",
|
57
|
+
"url": "git://github.com/oozcitak/xmlbuilder-js.git"
|
58
|
+
},
|
59
|
+
"scripts": {
|
60
|
+
"postpublish": "rm -rf lib",
|
61
|
+
"prepublish": "coffee -co lib src",
|
62
|
+
"test": "mocha \"test/**/*.coffee\" && istanbul report text lcov"
|
63
|
+
},
|
64
|
+
"version": "9.0.7"
|
65
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"requires": true,
|
3
|
+
"lockfileVersion": 1,
|
4
|
+
"dependencies": {
|
5
|
+
"sax": {
|
6
|
+
"version": "1.2.4",
|
7
|
+
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
|
8
|
+
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
|
9
|
+
},
|
10
|
+
"xml2js": {
|
11
|
+
"version": "0.4.19",
|
12
|
+
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz",
|
13
|
+
"integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==",
|
14
|
+
"requires": {
|
15
|
+
"sax": ">=0.6.0",
|
16
|
+
"xmlbuilder": "~9.0.1"
|
17
|
+
}
|
18
|
+
},
|
19
|
+
"xmlbuilder": {
|
20
|
+
"version": "9.0.7",
|
21
|
+
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
|
22
|
+
"integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0="
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
let Parser = require('xml2js').Parser
|
2
|
+
let readFile = require('fs').readFile
|
3
|
+
let writeFile = require('fs').writeFile
|
4
|
+
|
5
|
+
let parseOpts = {
|
6
|
+
trim: true,
|
7
|
+
normalizeTags: true,
|
8
|
+
normalize: true
|
9
|
+
}
|
10
|
+
let parser = new Parser(parseOpts)
|
11
|
+
let fileName = process.argv[2]
|
12
|
+
let outFile = process.argv[3]
|
13
|
+
let parseFile = (data) =>{
|
14
|
+
parser.parseString(data, (parseErr, result) => {
|
15
|
+
if(parseErr){
|
16
|
+
throw parseErr
|
17
|
+
}
|
18
|
+
writeFile(outFile, JSON.stringify(result), (err) => {
|
19
|
+
if (err) {
|
20
|
+
throw err
|
21
|
+
}
|
22
|
+
})
|
23
|
+
})
|
24
|
+
}
|
25
|
+
|
26
|
+
readFile(fileName, (err, data) => {
|
27
|
+
if(err) {
|
28
|
+
throw err
|
29
|
+
}
|
30
|
+
parseFile(data)
|
31
|
+
return
|
32
|
+
})
|
33
|
+
|