From 45dc488da0afa7e4f76907cadfada8842a409c3c Mon Sep 17 00:00:00 2001 From: Elia C Date: Wed, 11 May 2016 18:14:50 +0200 Subject: [PATCH] Fixing issue #39: XML with list of objects issues #39 Parsing xml with multile child with same name now result in array --- soapclient.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/soapclient.js b/soapclient.js index 70e765f..3df3c60 100644 --- a/soapclient.js +++ b/soapclient.js @@ -246,8 +246,21 @@ SOAPClient._node2object = function(node, wsdlTypes) obj = new Object(); for(var i = 0; i < node.childNodes.length; i++) { - var p = SOAPClient._node2object(node.childNodes[i], wsdlTypes); - obj[node.childNodes[i].nodeName] = p; + var p = SOAPClient._node2object(node.childNodes[i], wsdlTypes); + // obj[node.childNodes[i].nodeName] = p; + + if (obj[node.childNodes[i].nodeName]) { + if (obj[node.childNodes[i].nodeName].push) { + obj[node.childNodes[i].nodeName].push(p); + } + else { + var val = obj[node.childNodes[i].nodeName]; + obj[node.childNodes[i].nodeName] = new Array(val, p); + } + } + else { + obj[node.childNodes[i].nodeName] = p; + } } return obj; }