0

我在访问 vba 上使用这个简单的子

Public Sub ReadXml()
    ' XML FILE:
    ' <A>
    '     <B>sometext</B>
    ' </A>
    Dim n As New MSXML2.DOMDocument60
    Dim n1 As MSXML2.IXMLDOMNode
    Const NomeFile = "C:\file.xml"
    n.async = False
    n.validateOnParse = False
    If n.Load(NomeFile) Then
        Set n1 = n.selectSingleNode("A/B")
        Debug.Print n1.Text ' <===  error
    End If
End Sub

运行时我收到 91 运行时错误

4

1 回答 1

0

XPath inselectSingleNode()应该是“A/B”(正斜杠,而不是您使用的反斜杠)

于 2019-04-13T16:45:16.320 回答