bundles/org.eclipse.orion.client.ui/web/orion/widgets/themes/ThemeImporter.js
function xmlToJson(xml) {
            // Create the return object
            var obj = {};
            if (xml.nodeType === 1) { // element
                // do attributes
                if (xml.attributes.length > 0) {
                    for (var j = 0; j < xml.attributes.length; j++) {
                        var attribute = xml.attributes.item(j);
                        obj[attribute.nodeName] = attribute.value;
                    }
                }
            } else if (xml.nodeType === 3) { // text
                obj = xml.nodeValue.trim(); // add trim here
            }
            // do children
            if (xml.hasChildNodes()) {
                for (var i = 0; i < xml.childNodes.length; i++) {
                    var item = xml.childNodes.item(i);
                    var nodeName = item.nodeName;
                    if (typeof(obj[nodeName]) === "undefined") { //$NON-NLS-0$
                        var tmp = xmlToJson(item);
                        if (tmp !== "") // if not empty string
                            obj[nodeName] = tmp;
                    } else {
                        if (typeof(obj[nodeName].push) === "undefined") { //$NON-NLS-0$
                            var old = obj[nodeName];
                            obj[nodeName] = [];
                            obj[nodeName].push(old);
                        }
                        tmp = xmlToJson(item);
                        if (tmp !== "") // if not empty string
                            obj[nodeName].push(tmp);
                    }
                }
            }
            return obj;
        }
function xmlToJson(xml) {
            // Create the return object
            var obj = {};
            if (xml.nodeType === 1) { // element
                // do attributes
                if (xml.attributes.length > 0) {
                    for (var j = 0; j < xml.attributes.length; j++) {
                        var attribute = xml.attributes.item(j);
                        obj[attribute.nodeName] = attribute.value;
                    }
                }
            } else if (xml.nodeType === 3) { // text
                obj = xml.nodeValue.trim(); // add trim here
            }
            // do children
            if (xml.hasChildNodes()) {
                for (var i = 0; i < xml.childNodes.length; i++) {
                    var item = xml.childNodes.item(i);
                    var nodeName = item.nodeName;
                    if (typeof(obj[nodeName]) === "undefined") { //$NON-NLS-0$
                        var tmp = xmlToJson(item);
                        if (tmp !== "") // if not empty string
                            obj[nodeName] = tmp;
                    } else {
                        if (typeof(obj[nodeName].push) === "undefined") { //$NON-NLS-0$
                            var old = obj[nodeName];
                            obj[nodeName] = [];
                            obj[nodeName].push(old);
                        }
                        tmp = xmlToJson(item);
                        if (tmp !== "") // if not empty string
                            obj[nodeName].push(tmp);
                    }
                }
            }
            return obj;
        }
function xmlToJson ( xml ) { // Create the return object
 var obj = { } ; if ( xml . nodeType === 1 ) { // element
 // do attributes
 if ( xml . attributes . length > 0 ) { for ( var j = 0 ; j < xml . attributes . length ; j ++ ) { var attribute = xml . attributes . item ( j ) ; obj [ attribute . nodeName ] = attribute . value ; } } } else if ( xml . nodeType === 3 ) { // text
 obj = xml . nodeValue . trim ( ) ; // add trim here
 } // do children
 if ( xml . hasChildNodes ( ) ) { for ( var i = 0 ; i < xml . childNodes . length ; i ++ ) { var item = xml . childNodes . item ( i ) ; var nodeName = item . nodeName ; if ( typeof ( obj [ nodeName ] ) === "undefined" ) { //$NON-NLS-0$
 var tmp = xmlToJson ( item ) ; if ( tmp !== "" ) // if not empty string
 obj [ nodeName ] = tmp ; } else { if ( typeof ( obj [ nodeName ] . push ) === "undefined" ) { //$NON-NLS-0$
 var old = obj [ nodeName ] ; obj [ nodeName ] = [ ] ; obj [ nodeName ] . push ( old ) ; } tmp = xmlToJson ( item ) ; if ( tmp !== "" ) // if not empty string
 obj [ nodeName ] . push ( tmp ) ; } } } return obj ; }
Changes XML to JSON
Changes XML to JSON