Pages

Tuesday, February 19, 2013

eq operator in coldfusion is case insenitive (:) very easy to mistake)

eq operator in coldfusion is case insensitive

its very common mistake. remember eq operator in coldfusion is case insensitive.
see below example.

<cfset a = "USD">
<cfset b = "usd">

<cfif a  eq b >   
    <cfoutput>
        yes
    </cfoutput>
<cfelse>       
    <cfoutput>
        else
    </cfoutput>
</cfif>

Friday, February 15, 2013

how to check if attribute exists in a xml node in coldfusion

how to check if attribute exists in a xml node in coldfusion



<cfif structKeyExists( node[1].xmlAttributes, "name" )>                                   
            <cfset statefileName = node[1].xmlAttributes.name/>
<cfelse>
           <cfset statefileName = ""/>
</cfif>


here Name is attribute thats i am trying to know if it is defined or not. 
isdefined fuction will not work here in finding node or attribute.

structKeyExists will help in finding if an attribute is present in a node or not.