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!
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!