hi
i'm still newbie to xml thingy, do u think i can use <cftransaction and cftry 
into my code below?
<cfflush interval="10">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>XML to Database</title>
</head>
<body>
<!---parse XML via http--->
<cfhttp url="http://localhost:8500/templatemonsters-WEBAPI/01NOV-02NOV.xml"; 
method="GET" resolveurl="Yes" throwOnError="Yes"/>
<cfset Templates = XmlParse(CFHTTP.FileContent)>
<!--- The "root element" of this XML Object --->
<!--- is the <templates> element in the XML code--->
<CFSET templatesRoot = Templates.XmlRoot>
<!--- Let's grab the <company> element's "name" attribute
<CFSET templatesCompany = templatesRoot.XmlAttributes["company"]> --->
<!--- How many immediate children of <company> are there? --->
<CFSET templatesTotal = ArrayLen(templatesRoot.XmlChildren)>

<!---<cfoutput><p>#templatesCompany#</p><p>#templatesTotal#</p></cfoutput>--->

<CFOUTPUT>
<!--- Loop through each of the <location> elements --->
<CFLOOP FROM="1" TO="#templatesTotal#" INDEX="i">
<!--- Grab values from the XML document --->
<CFSET thisID = templatesRoot.XmlChildren[i]>
<!---<CFSET id = thisID.XmlAttributes["id"]>--->

<cfif thisID["state"].xmlText neq "2"
        and (thisID["template_type"]["type_id"].xmlText eq "1"
        or thisID["template_type"]["type_id"].xmlText eq "2" 
        or thisID["template_type"]["type_id"].xmlText eq "3"
        or thisID["template_type"]["type_id"].xmlText eq "9"
        or thisID["template_type"]["type_id"].xmlText eq "10")>
        <h3>#thisID["state"]#</h3>
                <!---xml to database - begin--->
                <p><tt>
                <em><strong>#thisID["id"].xmlText#</strong></em><br />
                Price#thisID["price"].xmlText#
                (Unique#thisID["exc_price"].xmlText#)<br />
                Type #thisID["template_type"]["type_id"].xmlText#<br />
                
                <cfif not #structIsEmpty(thisID["screenshots_list"])#>
                <cfset findDIR = 
getDirectoryFromPath(thisID["screenshots_list"]["screenshot"][1]["uri"].xmlText)>
              
                Directory 
#ReplaceList(findDIR,"http://,images.templatemonster.com/screenshots/,/";, 
"")#<br />
                
                <cfloop
                        from="1"
                        to="#ArrayLen(thisID.screenshots_list.screenshot)#"
                        index="the_screenshot_list">
                        
                        <cfset 
                                screenshotToFind = 
                                
getFileFromPath(thisID["screenshots_list"]["screenshot"][the_screenshot_list]["uri"].xmlText)>
                        <cfif
                                screenshotToFind contains 
"#thisID["id"].xmlText#-m.jpg" or
                                screenshotToFind contains 
"#thisID["id"].xmlText#-b.jpg">
                                #getFileFromPath(
                                
thisID["screenshots_list"]["screenshot"][the_screenshot_list]["uri"].xmlText
                                )#,
                        </cfif>
                        
                </cfloop>
                        <cfelse>
                Null
                </cfif>
                </tt></p>
                <!---xml to database - end--->
</cfif>


</CFLOOP>
</CFOUTPUT>



</body>
</html>







>>Figured someone would know and answer quicker than me testing this. 
>>
>>Can you wrap a query with cftry inside a cftransaction? 
>>
>>Thanks,
>>Will
>
>I do this all the time in my CFCs...
>
><cftransaction>
>    <cftry>
>        <cfquery>
>            <!--- Query here --->
>        </cfquery>
>        <cfquery>
>            <!--- Another query here --->
>        </cfquery>
>    <cfcatch type="database">
>        <cftransaction action="rollback" />
>        <cfreturn false />
>    </cfcatch>
>    
>    <!--- If no database errors caught, commit transaction --->
>    <cftransaction action="commit" />
></cftransaction>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:259726
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to