From a7c773372b8c0fa10553dccf8cdf8ee33b84a65b Mon Sep 17 00:00:00 2001 From: JC Brand Date: Fri, 19 Apr 2013 00:30:56 +0200 Subject: [PATCH] Remove xml2json, not being used --- Libraries/xml2json.js | 155 ------------------------------------------ 1 file changed, 155 deletions(-) delete mode 100644 Libraries/xml2json.js diff --git a/Libraries/xml2json.js b/Libraries/xml2json.js deleted file mode 100644 index 23650febb..000000000 --- a/Libraries/xml2json.js +++ /dev/null @@ -1,155 +0,0 @@ -/* This work is licensed under Creative Commons GNU LGPL License. - - License: http://creativecommons.org/licenses/LGPL/2.1/ - Version: 0.9 - Author: Stefan Goessner/2006 - Web: http://goessner.net/ -*/ -function xml2json(xml, tab) { - var X = { - toObj: function(xml) { - var o = {}; - if (xml.nodeType==1) { // element node .. - if (xml.attributes.length) // element with attributes .. - for (var i=0; i 1) - o = X.escape(X.innerXml(xml)); - else - for (var n=xml.firstChild; n; n=n.nextSibling) - o["#cdata"] = X.escape(n.nodeValue); - } - } - if (!xml.attributes.length && !xml.firstChild) o = null; - } - else if (xml.nodeType==9) { // document.node - o = X.toObj(xml.documentElement); - } - else - alert("unhandled node type: " + xml.nodeType); - return o; - }, - toJson: function(o, name, ind) { - var json = name ? ("\""+name+"\"") : ""; - if (o instanceof Array) { - for (var i=0,n=o.length; i 1 ? ("\n"+ind+"\t"+o.join(",\n"+ind+"\t")+"\n"+ind) : o.join("")) + "]"; - } - else if (o == null) - json += (name&&":") + "null"; - else if (typeof(o) == "object") { - var arr = []; - for (var m in o) - arr[arr.length] = X.toJson(o[m], m, ind+"\t"); - json += (name?":{":"{") + (arr.length > 1 ? ("\n"+ind+"\t"+arr.join(",\n"+ind+"\t")+"\n"+ind) : arr.join("")) + "}"; - } - else if (typeof(o) == "string") - json += (name&&":") + "\"" + o.toString() + "\""; - else - json += (name&&":") + o.toString(); - return json; - }, - innerXml: function(node) { - var s = "" - if ("innerHTML" in node) - s = node.innerHTML; - else { - var asXml = function(n) { - var s = ""; - if (n.nodeType == 1) { - s += "<" + n.nodeName; - for (var i=0; i"; - } - else - s += "/>"; - } - else if (n.nodeType == 3) - s += n.nodeValue; - else if (n.nodeType == 4) - s += ""; - return s; - }; - for (var c=node.firstChild; c; c=c.nextSibling) - s += asXml(c); - } - return s; - }, - escape: function(txt) { - return txt.replace(/[\\]/g, "\\\\") - .replace(/[\"]/g, '\\"') - .replace(/[\n]/g, '\\n') - .replace(/[\r]/g, '\\r'); - }, - removeWhite: function(e) { - e.normalize(); - for (var n = e.firstChild; n; ) { - if (n.nodeType == 3) { // text node - if (!n.nodeValue.match(/[^ \f\n\r\t\v]/)) { // pure whitespace text node - var nxt = n.nextSibling; - e.removeChild(n); - n = nxt; - } - else - n = n.nextSibling; - } - else if (n.nodeType == 1) { // element node - X.removeWhite(n); - n = n.nextSibling; - } - else // any other node - n = n.nextSibling; - } - return e; - } - }; - if (xml.nodeType == 9) // document node - xml = xml.documentElement; - var json = X.toJson(X.toObj(X.removeWhite(xml)), xml.nodeName, "\t"); - return "{\n" + tab + (tab ? json.replace(/\t/g, tab) : json.replace(/\t|\n/g, "")) + "\n}"; -}