Pages

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.

2 comments: