Parse responseXML in VBA (1 Viewer)

mjcaestecker

Registered User.
Local time
Today, 09:47
Joined
Aug 17, 2012
Messages
25
Greetings all,

This is a simple question, but i cannot seem to find an understandable answer anywhere... How do you parse a responseXML after you get the response from a webserver? Here's the code i have so far to get the response.

Code:
    Dim Execute As New MSXML2.ServerXMLHTTP
    Dim Response As String
    
    Dim URL As String
    Dim username As String
    Dim password As String
    
    username = "username"
    password = "password"

    URL = "https://api.test.com/process"
    Execute.Open "GET", URL, False, username, password
    Execute.send
    Response = Execute.responseText

And here's what the responseText looks like (simplified a little bit for security's sake)
Code:
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
  <link href="/process" rel="edit"></link>
  <id>http://api.test.com/process</id>
  <title type="text">Contact: johnsample@gmail.com</title>
  <updated>2013-01-18T05:10:46.174Z</updated>
  <author>
    <name>Constant Contact</name>
  </author>
  <content type="application/vnd.ctct+xml">
    <Contact xmlns="http://ws.test.com/ns/1.0/" id="http://api.test.com/">
      <Status>Active</Status>
      <EmailAddress>johnsample@gmail.com</EmailAddress>
      <EmailType>HTML</EmailType>
      <Name>John Sample</Name>
      <FirstName>John</FirstName>
      <MiddleName></MiddleName>
      <LastName>Sample</LastName>
      <CustomField1>1234</CustomField1>
      <CustomField2>0</CustomField2>
    </Contact>
  </content>
</entry>

The part I cannot seem to find is how to parse things like the nodes EmailAddress or Name out of the responseText. Can someone help me out?

Cheers,

-Martin
 

Users who are viewing this thread

Top Bottom