Hi Ann, I think I've read your book: Mastering XML - Published by Sybex
Any way, here's how I'm pulling attributes out of an XML doc in CF.
<cfscript>
objDOM = CreateObject("COM", "Microsoft.XMLDom");
objDOM.async = false;
objDOM.load(attributes.xml_layout);
root_node = objDOM.documentElement;
items = objDOM.getElementsByTagName("afxml:field");
n_items = items.length;
//WriteOutput("<ul>");
for (i = 0; i lt n_items ; i = i + 1)
{
node = items.item(i);
map_node = node.attributes;
name = map_node.getnameditem("name");
name = name.text;
value = map_node.getnameditem("value");
value = value.text;
taborder = map_node.getnameditem("taborder");
taborder = taborder.text;
}
...snip...
so you can see that I have a list of nodes I'm going through, but I'm
retrieve specific attributes with the 'map_node.getnameditem("name")'
part... so for you:
(after loading the xml doc)
items = objDOM.getElementsByTagName("pp.authresponse");
n_items = items.length;
for (i = 0; i lt n_items ; i = i + 1)
{
node = items.item(i);
map_node = node.attributes;
//the following would retrive the ordernumber
attribute...
ordernumber = map_node.getnameditem("ordernumber");
ordernumber = name.text;
//etc....
}
Does that help?
-----Original Message-----
From: Ann Navarro [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 10, 2002 12:06 PM
To: [EMAIL PROTECTED]
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