What you want to do is save the response to a cold fusion variable so you
have one var to work with that contains the XML.  That header line

<!DOCTYPE pp.response PUBLIC "-//IMALL//DTD PUREPAYMENTS 1.0//EN" 
"http://www.purepayments.com/dtd/purepayments.dtd";>

   might give you trouble...  I'd parse it out so the variable contains pure
a pure XML snippet.

   So say you called your var #PostResponse# and it contains this:

<pp.response>
<pp.authresponse merchant="1001" ordernumber="1" authstatus="DCL" 
transactionid="CC_FU2CBD48812C" failure="true">Card
declined</pp.authresponse>
</pp.response>

   You then run this code (and this is counting that you have everything
installed properly):

<CF_XMLDatasource name="GetResponse">
#PostResponse#
</CF_XMLDatasource>

<CF_XMLQuery Datasource="GetResponse" type="SQL" Name="qryResponse">
  SELECT *
  FROM GetResponse
</CF_XMLQuery>

<cfoutput query="qryResponse">
   <CFSET TheValue = "#pp.authresponse_authstatus#">
</cfoutput>

  Now you should be able to use your:

<CFIF #TheValue# = "DCL">
     do this
<CFELSE>
     do that
</CFIF>


   I'm a little concerned about the dots too.  Might goof things up.  If
they appear to be causing problems, use #rereplace(PostResponse, ".", "",
"ALL")# to strip them out before running XML_Datasource on it. (and use
<CFSET TheValue = "#ppauthresponse_authstatus#">).

   I hope this helps...  If it doesn't, your 99% there, just need to tweak
what I gave you a little.  You always have to reference things with
"ELEMENTNAME_" and then the attribute or subfield, in your case
"pp.authresponse_".  That part isn't that obvious in the docs for torchbox.

   Good luck.


      Kipp Grose
      Database / Web Developer
      Charity.ca / Sentient Inc.
      [EMAIL PROTECTED] / [EMAIL PROTECTED]


-----Original Message-----
From: Ann Navarro
To: [EMAIL PROTECTED]
Sent: 9/10/02 1:05 PM
Subject: [cf-xml] accessing attribute values from Structures or SubSets

I need to access attribute values in an XML document returned to me from
a 
CFHTTP POST operation.

A typical response will look like:

<!DOCTYPE pp.response PUBLIC "-//IMALL//DTD PUREPAYMENTS 1.0//EN" 
"http://www.purepayments.com/dtd/purepayments.dtd";>
<pp.response>
<pp.authresponse merchant="1001" ordernumber="1" authstatus="DCL" 
transactionid="CC_FU2CBD48812C" failure="true">Card
declined</pp.authresponse>
</pp.response>


I specifically need to pull the last 3 attributes in the
<pp.authresponse> 
element.

I've tried several custom CF tags that turn the xml data into a
structure, 
but they're very complex structures, and the element names tend to get 
munged because of the period (which shouldn't happen, it's a valid name 
character).

So, I've installed XML Toolkit, and it looks promising, either by using 
subset or the xpath features.


Where I'm stuck is how to get the resulting xpath value into something I

can then use directly in CF --, e.g. <CFIF #value# = "DCL">
     do this
<CFELSE>
     do that

and then storing transaction ids in my database, etc.

So how do I assign those values to some 
object/structure/parameter/variable/whatever, that I can then manipulate
in 
CF?

Ann
-----
Ann Navarro, WebGeek, Inc.
http://www.webgeek.com

say what? http://www.snorf.net/blog


-----------------------+
cf-xml mailing list
http://torchbox.com/xml/list.cfm

-----------------------+
cf-xml mailing list
http://torchbox.com/xml/list.cfm

Reply via email to