As I explained in this answer link you can use the "synchronized" way (this is because it is a web application and not "Desktop"), for your case it should look like this:
Dim url
url = Server.MapPath("/pasta/aonde/esta/xml/exemplo.xml")
Set doc = CreateObject("MSXML2.DOMDocument")
doc.load url
doc.async = False
'Seleciona com XPATH
Set nodes = doc.SelectNodes("//DocumentStatus")
'Lê todos que encontrar
For Each node In nodes
Response.Write "ValId:" & node.Attributes.getNamedItem("ValId").Text & "<br>"
Next
Now if you want to read from an external server you may have to use MSXML2.XMLHTTP
, as in the other but simplified answer:
Dim xhr, url, doc
Set xhr = CreateObject("MSXML2.XMLHTTP")
url = "http://dominio/exemplo.xml" 'url da API
xhr.Open "GET", url, False
xhr.send
If xhr.status < 200 Or xhr.status >= 300 Then
'Algo falhou, as vezes pode haver uma descrição em 'xhr.responseText' ou pode retornar vazio, o 'xhr.status' indica o tipo de erro
MsgBox "Erro HTTP:" & xhr.status & " - Detalhes: " & xhr.responseText
Else
'Faz o parse da String para XML
Set doc = CreateObject("MSXML2.DOMDocument")
doc.loadXML(xhr.responseText)
'Seleciona com XPATH
Set nodes = doc.SelectNodes("//DocumentStatus")
'Lê todos que encontrar
For Each node In nodes
Response.Write "ValId:" & node.Attributes.getNamedItem("ValId").Text & "<br>"
Next
End If
Of course I understand that this is SOAP, and probably the sending is done via POST, but if that is the case then I believe you have already done the HTTP request part and its only need to read as Xml, so if this is I think that maybe xhr.ResponseXML
will already work (I will review the code for both responses), but if it does not work, then with SelectNodes
within your response to SOAP sending execute this:
'Faz o parse da String para XML
Set doc = CreateObject("MSXML2.DOMDocument")
doc.loadXML(<aqui vai o teu responseText>)
'Seleciona com XPATH
Set nodes = doc.SelectNodes("//DocumentStatus")
'Lê todos que encontrar
For Each node In nodes
Response.Write "ValId:" & node.Attributes.getNamedItem("ValId").Text & "<br>"
Next
I promise to see the possibility of simple codes