Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Parse XML with asp

How do read the responseXML to retrieve values

12:04 am on Dec 24, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 29, 2004
posts: 84
votes: 0

I am using asp and sending data to my payment gateway for processing. When processed it returns xml back to me that I use. How do I get the values from this response?

Response would be returned in this format:

<?xml version="1.0" encoding="UTF-8"?>
<TransTime>Mon Nov 08 20:21:06 PST 2004</TransTime>

This is the code I am using to test with for now:

set xml = Server.CreateObject("Microsoft.XMLHTTP")
set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")

xml.open "POST", "##HOST ADDRESS##", false
xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xml.send (orderString)
xmlResponseStr = xml.responseText
Response.Write("<br /><br />")

' Parse Returned XML
set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async = True

Set itemList = xmlDoc.getElementsByTagName("*")

Dim xmlApproved

Response.Write("<br /><br />")

For Each item In itemList
Response.Write("IN HERE")
For each child in item.childNodes
Response.Write("IN DEEPER")
Response.Write("<br /><br />")

Set xmlDoc = Nothing
Set itemList = Nothing
Set xml = nothing

As you may see this is the first time I have ever attempted something like this.

12:51 am on Dec 24, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 29, 2004
posts: 84
votes: 0

Would also like to have it work on all browsers. (not sure if that is an issue or not)
6:41 pm on Dec 24, 2008 (gmt 0)

Senior Member from CA 

WebmasterWorld Senior Member httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 29, 2003
votes: 0

instead of looping, you may try an XPATH expression to find and display the values you need. Search for "xpath vb" for some good tutorials.

Since the code is executing on the server, you needn't worry about browser consistency.