//外部必须为<xml>
var xmlTemp = "<xml><GoodsInfo><ProductName>20110613云实丝棉拉架连衣裙</ProductName><ColorID>348</ColorID><SizeID>560</SizeID><ProductID>101863</ProductID><GoodImagePath>/uploadfiles/GoodImage/101863348/big2011_09_15_06_16_43_3618.jpg</GoodImagePath></GoodsInfo><GoodsInfo><ProductName>【抢果果.特】薄型纯棉阔腿裤牛仔裤 不显臀围7023 原价168</ProductName><ColorID>308</ColorID><SizeID>535</SizeID><ProductID>101559</ProductID><GoodImagePath>/uploadfiles/GoodImage/101559308/big2011_10_31_03_44_55_0595.jpg</GoodImagePath></GoodsInfo></xml>"; var xmldom = null; //判断IE浏览器 if (window.ActiveXObject) { xmldom = new ActiveXObject("Microsoft.XMLDOM"); xmldom.loadXML(xmlTemp); } else {
xmldom = new DOMParser().parseFromString(xmlTemp, "text/xml"); }
//查找根节点遍历 $(xmldom).find("GoodsInfo").each(function (index, object) { var GoodsInfo = $(object);
alert($(object).find("ProductID").text()) });
转载于:https://www.cnblogs.com/only-copy/articles/2440834.html