📄 navigate1.htm
字号:
<html>
<script Language="JavaScript">
var matchingNodes=null;
var position;
function getMatching(){
var searchName = xmlName.value;
matchingNodes = xmlDoc.documentElement.getElementsByTagName(searchName);
if (matchingNodes.length == 0){
alert("No matching nodes.");
status.innerHTML = "";
}
else{
position = 0;
setStatus();
rawXML.innerText = matchingNodes.item(0).xml;
}
}
function setStatus(){
navStatus.innerHTML = "Matching nodes: " + matchingNodes.length + " Current position: " + position;
}
function move(){
var newNode = matchingNodes.nextNode();
if (newNode == null){
alert("At end of list. I will reset the list to the beginning");
matchingNodes.reset();
newNode = matchingNodes.nextNode();
}
rawXML.innerText = newNode.xml;
position++;
setStatus();
}
function getRandom(){
var randomNode = nodeNumber.value;
var newNode = matchingNodes.item(randomNode);
if (newNode == null)
alert("Node does not exist.");
else
alert(newNode.xml);
}
</script>
<body>
<p align="center"><b>Get Named Node Example</b></p>
<xml ID="xmlDoc" src="big.xml"></xml>
Search For:<input type="Text" ID="xmlName">
<input type="button" value="Find Matching" onClick="getMatching()"><BR>
<div ID="navStatus"> </div>
<p><input type="button" value="Move Next" onClick="move()"></p>
<p>Nodes XML:</p>
<div ID="rawXML"> </div>
<p>Look Up Node Number:<input type="Text" ID="nodeNumber" length="4">
<input type="button" value="Get Node's XML" onClick="getRandom()"></p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -