例9-2.html

来自「深入浅出XML示例下载」· HTML 代码 · 共 28 行

HTML
28 行
字号
<html>
<head>
<title>节点及节点接口的应用</title>
</head>
<body>
<H1>添加元素示例</H1>
<xml id="isle" src="EX9_1.XML">
</xml>
<script language="vbscript">
  set mydoc=isle
  if mydoc.parseError<>0 Then
    MsgBox mydoc.parseError.reason
  Else
    set roote=mydoc.documentElement
    set childlist=roote.childNodes
    document.write "<p>添加元素前,元素的个数和最后一个元素名称为:</p>"
    document.write "<LI>" &childlist.length & "<BR> "
    document.write "<LI>" & roote.lastChild.nodeName & "<BR>"
    set newe1=mydoc.createElement("good")
    set dummy=roote.appendChild(newe1)
    document.write "<p>添加元素后,元素的个数和最后一个元素名称为:</p>"
    document.write "<LI>" & (childlist.length) & "<BR>"
    document.write "<LI>" & (roote.lastChild.nodeName) & "<BR>"
  End If
</script>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?