XML解析路径

XML解析路径

let xmlDoc;
let parser;
if (window.DOMParser) {
   parser = new DOMParser();
   //解决ie浏览器下标签不成对的问题
   let data = rs.data.replace(/(\<hr\>)+/g,'');
   xmlDoc = parser.parseFromString(data, "text/xml");
}
else // Internet Explorer
{
   xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
   xmlDoc.async = "false";
   xmlDoc.loadXML(txt);
}

//跟js类似,操作dom节点获取数据
let arr = xmlDoc.getElementsByTagName("a");				
let prefixPath = xmlDoc.getElementsByTagName("h1")[0].childNodes[0].nodeValue;