var xmlDoc=new ActiveXObject("MSXML.DOMDocument") xmlDoc.async=false; if(xmlDoc.loadXML(sXML) == true) { var item; items = xmldoc.selectNodes("//row"); for(i=0; i < items.length; i++) { item = items[i]; item.selectSingleNode("ttypecode").text; } }
for(var idx=0;idx<Vttype.length;idx++) { ttypeobj.options.length++; var xml_node=xml_Vttype.item(i); var xml_text_node=xml_node.selectSingleNode(ttypecode); ttypeobj.options[ttypeobj.options.length - 1].text=xml_text_node.childNodes.item(0).text; ttypeobj.options[ttypeobj.options.length - 1].value=xml_value_node.childNodes.item(1).text;
}
我试过了还是不行,你能不能在我写的基础上给改一下 function loadbook(tclassName,ttypeName) { var tclassobj = document.all(tclassName); var ttypeobj = document.all(ttypeName); var xmlhttp = document.all("xmlobj");
Vttype[idx].selectSingleNode("ttypename").text
xmlDoc.async=false;
if(xmlDoc.loadXML(sXML) == true)
{
var item;
items = xmldoc.selectNodes("//row");
for(i=0; i < items.length; i++)
{
item = items[i];
item.selectSingleNode("ttypecode").text;
}
}
{
ttypeobj.options.length++;
var xml_node=xml_Vttype.item(i);
var xml_text_node=xml_node.selectSingleNode(ttypecode);
ttypeobj.options[ttypeobj.options.length - 1].text=xml_text_node.childNodes.item(0).text;
ttypeobj.options[ttypeobj.options.length - 1].value=xml_value_node.childNodes.item(1).text;
}
function loadbook(tclassName,ttypeName) {
var tclassobj = document.all(tclassName);
var ttypeobj = document.all(ttypeName);
var xmlhttp = document.all("xmlobj");
ttypeobj.options.length = 0;
var file = tclassobj.options[tclassobj.selectedIndex].value;
xmlhttp.async = false;
xmlhttp.load(file);
var Vttype = xmlhttp.selectNodes("tclass/row");
var idx,name,idValue;
//运行到这时我的Vttype.length值为3这是对的,但我如何取得ttypecode 和 ttypename的值
for(idx = 0; idx < Vttype.length; idx ++) {
name = Vttype[idx].getAttribute("ttypename"); //这样写不对,取出来为null
idValue = Vttype[idx].getAttribute("ttypecode");//这样写不对,取出来为null
ttypeobj.options.length++;
ttypeobj.options[ttypeobj.options.length - 1].value = idValue;
ttypeobj.options[ttypeobj.options.length - 1].text = name;
}}