var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load("Tipsxml/tips.xml");
var firstinfo=xmlDoc.documentElement.selectSingleNode("Class[@name='文章管理']").childNodes;
for(var j=0;j<firstinfo.length;j++)
{
var newOption =window.document.createElement("OPTION");
if(firstinfo[j].getAttribute("name")!="")
newOption.text=firstinfo[j].getAttribute("name");
else
newOption.text="全部子类";
newOption.value=firstinfo[j].getAttribute("code");
drp2.options.add(newOption);
}
以上只是一段 js操作xml文件 的示例代码,大家在实用过程中,请根据情况修改。
希望对大家有启发!
JS操作XML示例
本文提供了一段使用JavaScript操作XML文件的示例代码,通过该代码可以读取XML文件并从中选择特定节点的数据来填充下拉菜单选项。

被折叠的 条评论
为什么被折叠?



