📄 16-8.htm
字号:
<html><head><title>访问XML元素</title>
<xml ID="xml1" SRC="16-2.xml"></xml>
<script language="javascript">
<!--
function readXMLDocument()
{
var document1, eventsNode, eventNode, peopleNode;
var nameNode, titleNode, displayText ;
var attributes, attendencePerson ;
document1= document.all("xml1").XMLDocument;
eventsNode = document1.documentElement;
eventNode = eventsNode.firstChild;
peopleNode = eventNode.lastChild;
personNode = peopleNode.lastChild;
nameNode = personNode.firstChild;
titleNode = nameNode.nextSibling;
attributes = personNode.attributes;
attendencePerson = attributes.getNamedItem("ATTENDENCE");
displayText = nameNode.firstChild.nodeValue
+ ' ' + titleNode.firstChild.nodeValue
+ " 为 " + attendencePerson.value;
div1.innerHTML=displayText;
}
//-->
</script>
</head>
<body>
<h1>访问XML元素</h1>
<input type="button" value="得到第三位客人的名字、职位与类别"
onclick="readXMLDocument()">
<br> <br>
<div id="div1"></div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -