I am getting a type mismatch (run timer error 13) for when parsing a web request response to an xml object in VBA.
The error is on this line:
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
CodePudding user response:
The loadXML Method is expecting a String. You don't show us what the exact object behind WebRequest
is but it looks like WebRequest.responseXML
might return an object.
From that same document it is suggested you can get the body as a string by doing this:
xmldoc.LoadXML WebRequest.responseXML.xml