VBA 中的 MSXML2.DOMDocument 加载函数失败

use*_*523 3 ms-access vba

我已经为以下问题苦苦挣扎了一段时间,但尚未找到解决方案。

有一个包含 XML 文件的 iShare 页面,我想使用 VBA 代码下载该文件,然后处理该 XML 文件并将其保存到 MS Access 数据库中。

我已经使用下面的代码大约 4 年了,它工作得很好,没有任何问题。但这周突然停止工作了。有什么想法吗?

代码:

Private Function GetRequests() As Boolean
  On Error GoTo ErrHandler

  Dim oDoc As MSXML2.DOMDocument
  Dim Url As String
  Dim sFileName As String

  Set oDoc = New MSXML2.DOMDocument
  oDoc.async = False
  Url = cUrlDatabase & "/" & cApplicationName & "/In/" & cReqXmlFile

  UpdateStatus "Loading " & cReqXmlFile

  If Not oDoc.Load(Url) Then
    c_sLastError = "Could not load XML " & Url
    GoTo EndProc
  End If

  sFileName = sPath & "\Data\requests.xml"

  oDoc.Save sFileName

  GetRequests = True
End Function
Run Code Online (Sandbox Code Playgroud)

代码在该oDoc.Load(Url)部分失败,返回错误。

Dav*_*Caz 5

以下是如何收集错误详细信息的示例:

      Dim xDoc As MSXML.DOMDocument
      Set xDoc = New MSXML.DOMDocument

      If xDoc.Load("C:\My Documents\cds.xml") Then
        ' The document loaded successfully.

      Else
        ' The document failed to load.

        Dim strErrText As String
        Dim xPE As MSXML.IXMLDOMParseError

        ' Obtain the ParseError object
        Set xPE = xDoc.parseError
        With xPE
            strErrText = "Your XML Document failed to load" & _
            "due the following error." & vbCrLf & _
            "Error #: " & .errorCode & ": " & xPE.reason & _
            "Line #: " & .Line & vbCrLf & _
            "Line Position: " & .linepos & vbCrLf & _
            "Position In File: " & .filepos & vbCrLf & _
            "Source Text: " & .srcText & vbCrLf & _
            "Document URL: " & .url
        End With

        MsgBox strErrText, vbExclamation End If

        Set xPE = Nothing
      End If
Run Code Online (Sandbox Code Playgroud)

示例取自此处