I have a web service which returns XML string similar to the one below:
<?xml version="1.0"?>
<Result>
<PersonID>991166187</PersonID>
<AddressID>1303836</AddressID>
</Result>
I need a VBScript code that will allow me to retrieve the values for PersonID
and AddressID
. My specific question is how can I retrieve value for PersonID
, i.e. 991166187
, from the XML string in my original post.
In terms of what I have tried, I have the following code:
Dim doc
Dim xmlString
Dim nodes
Dim idArray
xmlString = "<?xml version="1.0"?><Result><PersonID>991166187</PersonID><AddressID>1303836</Address‌​ID></Result>"
Set doc = CreateObject("MSXML2.DOMDocument")
doc.loadXML(xmlString)
'Set nodes = doc.selectNodes("Result/PersonID/AddressID")
nodes = doc.getElementsByTagName("PersonID")
For Each node In nodes
WScript.Echo "Person ID: " & node.text