function encode(code) { return code .replace(/%/g, "%25") .replace(//g, "%3E") .replace(/&/g, "%26") .replace(/#/g, "%23") .replace(/{/g, "%7B") .replace(/}/g, "%7D"); } function addXmlns(code) { if (code.indexOf("xmlns") === -1) { return code.replace(/