js请求解析xml

xml数据
<?xml version="1.0" encoding="utf-8"?>
<table>
    <node name="node1" id="0">
        <text title="test"  content="详情" />
        <img name="image" />
        <pic name="test.jpg" />
        <pic name="test1.jpg" />
        <pic name="test2.jpg" />
    </node>
    <node name="node2" id="1">
        <text title="test"  content="详情" />
        <img name="image" />
        <pic name="test.jpg" />
        <pic name="test1.jpg" />
        <pic name="test2.jpg" />
    </node>

</table>
 
请求xml
    $.ajax({
                url: './data/'+cityCode+'/lc_contect.xml',
                type: 'GET',
                dataType: 'xml',
                async: false,
                success: function(xml) {
                   //解析xml
                    });
                }
            });
 
解析xml
//遍历
$(xml).find('node').each(function() {
    var fieldObj = $(this);
    var fId = fieldObj.attr("id");//读取节点属性

});
 
原文链接:https://blog.csdn.net/u010177789/article/details/78337225

  

原文地址:https://www.cnblogs.com/sweeeper/p/11656122.html