var parser = new DOMParser(); var docXML = parser.parseFromString(readXml, "application/xml"); console.log(docXML); let config = docXML.querySelectorAll('config'); if (config.length != 0) { config.forEach(configElement => { console.log(JSON.stringify(configElement)); for (let j = 0; j < configElement.children.length; j++) { let row = configElement.children[j].innerHTML; let rowName = configElement.children[j].nodeName; //console.log(configElement.children[j].nodeName); //console.log(row); var mapTest = new Map(); mapTest.set(rowName, row); arr.push(mapTest); for (let k = 0; k < configElement.children[j].children.length; k++) { let row2Value = configElement.children[j].children[k].innerHTML; let row2Name = configElement.children[j].children[k].nodeName; //console.log(configElement.children[j].children[k].nodeName); //console.log(row); var mapTest2 = new Map(); mapTest.set(rowName, mapTest2.set({ row2Name, row2Value })); //mapTest.set(mapTest2.set(mapTest2.set(row2Name, row2Value))); } } }); } else { console.log("XML do not have tag config"); }