在決議對 VBA 中的 xml 物件的 Web 請求回應時,出現型別不匹配(運行計時器錯誤 13)。
錯誤在這一行:
xmldoc.LoadXML WebRequest.responseXML
WebRequest.Open "POST", urlRef, False
WebRequest.setRequestHeader "Content-Type", "application/soap xml; charset=utf-8"
WebRequest.setRequestHeader "SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetURLSegments"
strRequest = _
"<?xml version='1.0' encoding='utf-8'?> " & _
"soap12:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap12='http://www.w3.org/2003/05/soap-envelope'> " & _
" <soap12:Body> " & _
" <GetURLSegments xmlns='http://schemas.microsoft.com/sharepoint/soap/'> " & _
" <strURL>" & strDocUrl & "</strURL>" & _
" </GetURLSegments>" & _
" </soap12:Body> " & _
"</soap12:Envelope>"
WebRequest.send strRequest
Dim xmldoc As Object
Set xmldoc = CreateObject("Msxml2.DOMDocument.6.0")
xmldoc.SetProperty "SelectionLanguage", "XPath"
xmldoc.LoadXML WebRequest.responseXML
For Each xmlnode In xmldoc.SelectNodes("//*[contains(name(),'strItemID')]")
Debug.Print xmlnode.Text
Next
uj5u.com熱心網友回復:
loadXML方法需要一個字串。您沒有向我們展示背后的確切物件WebRequest是什么,但它看起來WebRequest.responseXML可能會回傳一個 object。
從同一份檔案中,建議您可以通過執行以下操作將正文作為字串獲取:
xmldoc.LoadXML WebRequest.responseXML.xml
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/449916.html
上一篇:如果條件存在,VBA自動過濾
