ASP XML selectSingleNode problem

Posted on 2003-03-04
Medium Priority
Last Modified: 2007-12-19
I'm having some trouble parsing an XML document I'm getting from my company's bank in response to a XML document I'm sending.  Both docs are transferring fine, and in fact if the transaction in the document I send is accepted (valid credit card), everything parses perfectly.  The prob is when the transaction is not accepted by the bank server (invalid credit card), and the document that's returned to me has different tags.

I'm using the selectSingleNode method to get the text from the correct tag, and it works perfectly when the tag is there.

Here is the offending VBScript line

AuthCode = xmlDocument.selectSingleNode("//Transaction//AuthCode").Text

A valid credit card will result in a return document with an AuthCode tag inside a Transaction tag, and the above code grabs the text from it perfectly.

An invalid credit credit card returns a document that does not possess the AuthCode tag, and I get the following error on the line number where I set AuthCode:

Microsoft VBScript runtime error '800a01a8'
Object required: 'xmlDocument.selectSingleNode(...)'

According to documentation at MSDN, selectSingleNode should return a null value when the pattern is not matched.  It is instead causing this error, which is making the capture of data from an invalid transaction impossible.

Have tried this as well:

AuthCode = Null
AuthCode = xmlDocument.selectSingleNode("//Transaction//AuthCode").Text

If AuthCode Is Null Then ...

Which merely return this on the line of the if statement:

Microsoft VBScript runtime error '800a01a8'

Object required

I have updated my Win2K server to have the .NET framework, as well as MDAC 2.7, to no avail.

Any ideas?
Question by:ultmast
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

mikkolsoft earned 300 total points
ID: 8065875
Probably you have to grab the node to see if it exists before you ask for its text, like:

set AuthCodeObj = xmlDocument.selectSingleNode("//Transaction//AuthCode")
if not AuthCodeObj is nothing then
  AuthCode = AuthCodeObj.text

end if


Author Comment

ID: 8067994
It appears to work perfectly.  I had never tried to "set" the object without referencing the text associated with it.

Was almost to the point of having to redo the entire thing in JScript.

Thank you much.

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question