?? 4-17.html
字號:
<html>
<head>
<title>讀取XML標記的屬性值</title>
<script language="javascript">
function GetAttribute()
{
var document_xml = new ActiveXObject("Microsoft.XMLDOM");
document_xml.load("info.xml");
var basicNode = document_xml.getElementsByTagName("basic"); //獲得文檔的所有<basic>標記
var nameNode = document_xml.getElementsByTagName("name"); //獲得文檔的<name>標記
var basic_attribute = basicNode(0).attributes; //獲得<basic>標記的屬性
var name_attribute = nameNode(0).attributes; //獲得<name>標記的屬性
var str = "國籍是:"+basic_attribute.getNamedItem("country").value+
"\n名字中有"+name_attribute.getNamedItem("num").value+"個字"; //讀出這些屬性中某個特定的屬性的值
alert(str);
}
</script>
</head>
<body>
<input type="button" name="Submit" value="按鈕" onClick="GetAttribute()">
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -