解析xml


    /**
   * 解析xml结构
   * @param xmlStr
   */
    var getDecodeXml = function (str) {
        var ret = "";
        var parser = new DOMParser();
        var xmlDoc = parser.parseFromString(str, "text/xml");
        var nodes = xmlDoc.getElementsByTagName('diagram');

        for (var i = 0; i < nodes.length; i++) {
            var nr = nodes[i].textContent;
            ret += nr + "\n";
        }
        return ret;
    }

你可能感兴趣的:(解析xml)