JavaScript中获取XML数据流中数据节点的方法
var drp = document.getElementById(ddlID);
var oHttpReq = new ActiveXObject("MSXML2.XMLHTTP");
var oDoc = new ActiveXObject("MSXML2.DOMDocument");
oHttpReq.open("POST", "LoadDropDownList.aspx?ID="+SelectID, false);
oHttpReq.send("");
result = oHttpReq.responseText;
oDoc.loadXML(result);
var xmlObj = oDoc.documentElement;
var ss_id,ss_name;
for (var i=0;i<xmlObj.childNodes.length;i++)
{
ss_id=xmlObj.childNodes(i).childNodes(0).text; //获取数据节点1
ss_name=xmlObj.childNodes(i).childNodes(1).text; //获取数据节点2
drp.add(document.createElement("OPTION"));
drp.options[i].text=ss_name;
drp.options[i].value=ss_id;
}
posted on 2005-11-12 15:11 ............. 阅读(1269) 评论(0) 编辑 收藏 举报