日期:2014-05-16 浏览次数:20302 次
<html> <head> <title> 数据岛的显示 </title> <style type="text/css"> #findPanel { position:absolute; width:220px; border:1px solid #666666; } #findPanelTitle { height:10px; background-color:#336699; cursor:move; } #findPanelContent { padding:5px 5px 5px 5px; background-color:#6699CC; } </style> </head> <body> <SCRIPT LANGUAGE="JavaScript"> <!-- var xmlDoc = new ActiveXObject("Msxml2.DOMDocument"); xmlDoc.async = false; xmlDoc.resolveExternals = false; xmlDoc.load("stu.xml"); //alert(xmlDoc.xml); //显示数据 function show(){ var vbo = document.getElementById("s").value; if(vbo=="显示学生信息"){ document.getElementById('info').style.visibility='visible'; document.getElementById("s").value="隐藏学生信息"; }else{ document.getElementById('info').style.visibility='hidden'; document.getElementById("s").value="显示学生信息"; } } //查找 function que(){ document.getElementById("ad").style.visibility="visible"; document.getElementById("qmd").style.visibility="visible"; } /** * 解析XML文件函数 * @param xmlDoc XML对象 * @param name 属性名称 格式如:user.name */ function getXMLProperty(xmlDoc, name) { var keys = name.split('.'); var node = xmlDoc.documentElement; for(var i=0; i<keys.length; i++) { var childs = node.childNodes; var key = keys[i]; for(var k=0; k<childs.length; k++) { var child = childs[k]; if(child.nodeName == key) { if(child.childNodes.length == 1) { return child.text; } else { node = child; break; } } } } return ""; } //返回父节点(通过节点名字和节点值) function getNod(nam,val){ var node = xmlDoc.documentElement; var childs = node.childNodes; for (var i=0;i<childs.length ;i++ ) { var child = childs[i]; var childms = child.childNodes; for(var k=0;k<childms.length;k++){ var childm = childms[k]; if(childm.nodeName == nam && (childm.text).substring(0,6)==val){ //alert(val); return child; } } } return ''; } //通过父节点和子节点名返回子节点值 function getNodVal(nods,nam){ var childms = nods.childNodes; for(var k=0;k<childms.length;k++){ var childm = childms[k]; if(childm.nodeName == nam){ //alert(childm.text); return childm.text; } } return ''; } //通过父节点和子节点名返回子节点 function getCurNod(nods,nam){ var childms = nods.childNodes; for(var k=0;k<childms.length;k++){ var childm = childms[k]; if(childm.nodeName == nam){ //alert(childm.text); return childm; } } return ''; } //开始查找 function query(){ var renum = /^\d{5}$/; if(renum.exec(xh.value)){ if(xmlDoc.selectSingleNode("/学生管理[学生/学号="+xh.value+"]")){ var nod = getNod('学号',xh.value); //getNodVal(nod,'姓名'); //getNodVal(nod,'性别'); //getNodVal(nod,'籍贯'); /*document.getElementById("xm").value=xmlDoc.selectSingleNode("/学生管理[学生/学号="+xh.value+"]").selectSingleNode("学生