|
你把sub主体写到function主体里了这样当然报错,这样写吧。。。
Sub rTravel (rNode)
Dim blnTwo,childName
blnTwo = False
iLen = rNode.childNodes.length
If iLen > 0 Then
For i = 0 To rNode.childNodes.length -1
Set child = rNode.childNodes.item(i)
Call rTravel(child)
childName=child.nodeName 'Get the node name
If strName=childName then
MsgBox childName
childText = child.text
MsgBox childText
Exit Sub
End if
Next
Else
Exit Sub
End If
End Sub
Function ReadXMLvalue ( )
Dim xmlDoc,myErr,strName
strName="booker_ref_num"
Set xmlDoc = CreateObject("Microsoft.XMLDOM") '创建xml文档对象
xmlDoc.async = False '关闭异步加载,这样可确保在文档完整加载之前,解析器不会继续执行脚本
xmlDoc.load "c:\1.xml" '告知解析器加载名为 "c:\1.xml" 的文档,或者 xmlDoc.load("c:\1.xml");
If xmlDoc.parseError.errorCode <> 0 Then
Set myErr = xmlDoc.parseError
MsgBox("XML Loads Failed. " & myErr.reason)
Else
Set rootNode = xmlDoc.documentElement
Call rTravel(rootNode)
End If
call rTravel (rNode)
End Function |
|