Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

Commit 3b173cb

Browse files
committed
fixes issue when using the same instance of json2xml
1 parent 7871c83 commit 3b173cb

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/json2xml.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var xml = '';
2-
module.exports = function toXml(json) {
1+
module.exports = function toXml(json, xml) {
2+
var xml = xml || '';
33
if (json instanceof Buffer) {
44
json = json.toString();
55
}
@@ -26,12 +26,12 @@ module.exports = function toXml(json) {
2626
var l = elems.length;
2727
for (var j = 0; j < l; j++) {
2828
xml += '<' + key + '>';
29-
toXml(elems[j]);
29+
xml = toXml(elems[j], xml);
3030
xml += '</' + key + '>';
3131
}
3232
} else if (typeof(obj[key]) == 'object') {
3333
xml += '<' + key + '>';
34-
toXml(obj[key]);
34+
xml = toXml(obj[key], xml);
3535
xml += '</' + key + '>';
3636
} else if (typeof(obj[key]) == 'string') {
3737
if (key == '$t') {

0 commit comments

Comments
 (0)