Alt!! Ho beccato un punto e virgola di troppo che ti genera variabili globali!! Usa questa versione corretta:
codice:function buildValue(sValue) { if (/^\s*$/.test(sValue)) { return(null); } if (/^(true|false)$/i.test(sValue)) { return(sValue.toLowerCase() === "true"); } if (isFinite(sValue)) { return(parseFloat(sValue)); } if (isFinite(Date.parse(sValue))) { return(new Date(sValue)); } return(sValue); } function getXMLData (oXMLParent) { var vResult = /* true is the default value for empty nodes */ true, nLength = 0, sTxtContent = ""; if (oXMLParent.hasAttributes()) { vResult = {}; for (nLength; nLength < oXMLParent.attributes.length; nLength++) { iAttrib = oXMLParent.attributes.item(nLength); vResult["@" + iAttrib.nodeName.toLowerCase()] = buildValue(iAttrib.nodeValue.replace(/^\s+|\s+$/g, "")); } } if (oXMLParent.hasChildNodes()) { var iKey, iValue, iXMLChild; for (var iChildId = 0; iChildId < oXMLParent.childNodes.length; iChildId++) { iXMLChild = oXMLParent.childNodes.item(iChildId); if (iXMLChild.nodeType === 1 && !iXMLChild.prefix) { if (nLength === 0) { vResult = {}; } iKey = iXMLChild.nodeName.toLowerCase(); iValue = getXMLData(iXMLChild); if (vResult.hasOwnProperty(iKey)) { if (vResult[iKey].constructor !== Array) { vResult[iKey] = [vResult[iKey]]; } vResult[iKey].push(iValue); } else { vResult[iKey] = iValue; nLength++; } } else if (iXMLChild.nodeType === 3) { sTxtContent += iXMLChild.nodeValue.replace(/^\s+|\s+$/g, ""); } else if (iXMLChild.nodeType === 4) { sTxtContent += iXMLChild.nodeValue; } } } if (nLength > 0) { vResult.keyValue = buildValue(sTxtContent); Object.freeze(vResult); } else if (sTxtContent) { vResult = buildValue(sTxtContent); } return(vResult); }

Rispondi quotando