homepage Welcome to WebmasterWorld Guest from 54.197.94.241
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
Parse XML with asp
How do read the responseXML to retrieve values
humpg




msg:3813681
 12:04 am on Dec 24, 2008 (gmt 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"?>
<Result>
<TransTime>Mon Nov 08 20:21:06 PST 2004</TransTime>
<OrderID>2004110820210605147</OrderID>
<Approved>APPROVED</Approved>
<ReturnCode>Y:TEST:TESTTRANS:M:X:YYY</ReturnCode>
<ErrMsg></ErrMsg>
<TaxTotal>5.00</TaxTotal>
<ShipTotal>15.00</ShipTotal>
<SubTotal>55.00</SubTotal>
<FullTotal>75.00</FullTotal>
<PaymentType>CC</PaymentType>
<CardNumber>411111...1111</CardNumber>
<CardExpMonth>05</CardExpMonth>
<CardExpYear>07</CardExpYear>
<TransRefNumber>1bd0082c392b7c5b</TransRefNumber>
<CardIDResult>M</CardIDResult>
<AVSResult>X</AVSResult>
<CardAuthNumber>TEST</CardAuthNumber>
<CardRefNumber>TESTTRANS</CardRefNumber>
<CardType>VISA</CardType>
<IPResult>YYY</IPResult>
<IPCountry>CA</IPCountry>
<IPRegion>Ontario</IPRegion>
<IPCity>Toronto</IPCity>
</Result>

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 />")
Response.write(xmlResponseStr)

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

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(child.nodeName)
Response.Write("<br /><br />")
Next
Next

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.

 

humpg




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

Would also like to have it work on all browsers. (not sure if that is an issue or not)

httpwebwitch




msg:3814046
 6:41 pm on Dec 24, 2008 (gmt 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.

Cheers

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved