如何在VBScript中获取XML文件中节点的内容
我想在HTML页面中使用VBScript代码获得某个xml文件的节点内容,但是老是不对,很奇怪。HTML页面内容如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<title>DisplayAny</title>
<script language="VBSCRIPT">
Function Window_Onload()
test
End Function
Function test()
Dim xmlDoc
Set xmlDoc = CreateObject("Msxml2.DOMDocument.4.0")
Dim objNode
Dim text
xmlDoc.async = False
xmlDoc.resolveExternals = False
xmlDoc.Load "test.xml"
If (xmlDoc.parseError.errorCode <> 0) Then
msgbox "Error"
Exit Function
Else
Set objNode = XMLDoc.SelectSingleNode("//root/item")
If TypeName(objNode) = "Nothing" Then
msgbox "Nothing"
Exit Function
End If
text = objNode.parentNode.getAttributeNode("value").value
End If
msgbox text
End Function
</script>
</head>
<body scroll="no" topmargin="0" leftmargin="0" >
</body>
</html>
XML文件的内容如下:
<?xml version="1.0" encoding="GB2312"?>
<root>
<itme value= "666666"/>
</root>
结果每次都是弹出对话框"Error"。