木子屋 Dnawo's BLOG

VBScript、JavaScript判断xml节点是否存在

👤 dnawo 📅 2009-09-29 👁 7600 👍 0 💬 0 🔄 来源:本站原创
1).VBScript示例

HTML
<script type="text/vbscript">
Dim xmlDoc,node
Set xmlDoc = CreateObject("MSXML2.DOMDocument")
xmlDoc.loadXML("<xml><file/></xml>")
Set node = xmlDoc.selectSingleNode("xml/file")
If Not node is Nothing Then
	MsgBox "存在 file 节点!"
Else
	MsgBox "不存在 file 节点!"
End If
Set node = Nothing
Set xmlDoc = Nothing
</script>

2).JavaScript示例

HTML
<script type="text/javascript">
var xmlDoc,node
xmlDoc = new ActiveXObject("MSXML2.DOMDocument")
xmlDoc.loadXML("<xml><file/></xml>")
node = xmlDoc.selectSingleNode("xml/item")
if(node!=null)
	alert("存在 item 节点!")
else
	alert("不存在 item 节点!")
node = null
xmlDoc = null
</script>

评论(0)

暂无评论。

验证码
评论需审核通过后显示
← 上一篇 淘宝网开放平台回调参数top_parameters说明 下一篇 → VB6.0函数返回数组示例