Using cfif in coldfusion

For example, consider the following code snippet:

Scenario 1:

The name of the company I received as part of the SOAP response is as follows:

<Company>Amazon, Inc </Company>

Scenario 2:

Another company name that I received as part of the SOAP response is as follows:

<Company>Google, Inc </Company>

In principle, from the end of the user I entered some information and based on this I get different company names inside the tag <Company>.

The following code shows how I save the response in an XMLResponse variable

 <cfset XMLResponse = XmlParse(

    httpResponse.fileContent.Trim()

    ) />

The following code snippet shows how I parse the response and save the contents in a variable:

<cfset arrCOMPANY = XmlSearch(
             XMLResponse,
             "//*[name()='Company']"
             ) /> 

So now I have arrCOMPANY = Amazon, Inc, I get into the script and Google, Inc otherwise.

My question is:

, 1, - Amazon, Inc .

, , :

cfqueries, , :

<cfif arrCompany eq "Amazon, Inc">

// Here I will write cfquery with an integer field = 1


Or 

<cfif arrCompany eq "Google, Inc">

// Here I will write cfquery with integer field 0

, , , , eq, . (, Amazon Inc).

.

:

. :

CompanyName Amazon, Inc

<cfset CompanyName = Trim(arrCompany[1])>  // adding index 1 because  it a complex structure

cfif:

<cfif CompanyName eq "Amazon, Inc">

    <cfset m = 1>

    <cfelse>

    <cfset m = 0>  

    </cfif> 

    <cfoutput>#m#</cfoutput>

, 0 . , , .

+4
2

<cfset CompanyName = Trim(arrCompany[1])>

cfdump xmlFormat(), , node, . cfoutput, xml , , :

<cfoutput>#XMLFormat(CompanyName)#</cfoutput>

node, xmlText, :

<cfset CompanyName = trim( arrCompany[1].xmlText )>

: , , , bit. CF 1 0 , .

+1

XML. :

<cfset arrCOMPANY = trim(XmlSearch(
         XMLResponse,
         "//*[name()='Company']"
         )) />

,

a)
)

c) XML

0

All Articles