Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

isDefined with xml attribute

Status
Not open for further replies.

lucidtech

IS-IT--Management
Jan 17, 2005
267
US
I am trying to write CFML that checks whether or not an attribute exists withing an element of an XML document. I've gotten this to work with XMLChildren and elements, but cannot get it to work with attributes of elements.

Here is sample code :

<cfif isDefined("xmlDoc2.page.element.XmlAttribute.cost")>
<cfset cost = xmlDoc2.page.element.XmlAttributes["cost"]>
<cfelse>
<cfset cost = 0>
</cfif>

I'm checking for whether or not there is an attribute named "cost" and if it is set it to the attribute value, otherwise set the cost to 0. But everytime I run the script, whether the cost attribute exists or not, it is being set to 0.

Thanks in advance!

 
Go figure.. I make this post and 60 seconds later I find out the problem.

For anyone else who has this same problem, here is the correct syntax :

<cfif isXmlAttribute("xmlDoc2.page.element.XmlAttributes.cost")>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top