Skip to content

Instantly share code, notes, and snippets.

View demircancelebi's full-sized avatar

Demircan Celebi demircancelebi

View GitHub Profile
@demircancelebi
demircancelebi / xmlToJson.js
Last active September 1, 2023 12:40 — forked from chinchang/xmlToJson.js
Function to convert XML to JSON
// Changes XML to JSON
// Modified version from here: http://davidwalsh.name/convert-xml-json
xmlToJson(xml) {
// Create the return object
let obj = {};
if (xml.nodeType === 1) { // element
// do attributes
if (xml.attributes.length > 0) {
obj['@attributes'] = {};