<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
<script> var $xml = jQuery.noConflict(); </script>
<script type="text/javascript" src="http://www.jsons.cn/Down/jquery.json2xml.js"></script>
<script type="text/javascript" src="http://www.jsons.cn/Down/jquery.xml2json.js"></script>
//加载xml并转json
function LoadxmlToJson(path) {
var json_obj = null;
$.ajax({
async: false,
type: "get",
url: path,// "../Content/产品型号.xml",
dataType: "xml",
timeout: 1000, //设定超时
cache: false, //禁用缓存
success: function (xml) {//这里是解析xml
var str = $(xml).find("productinfo").html();
json_obj = $xml.xml2json("<productinfo>" + str + "</productinfo>");
return json_obj;
//alert(json_obj.product[0].pname);
}
});
return json_obj;
}