|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Performing a cfhttp on a returned string??
Im trying to perform a cfhttp on a string, which in this case is: #xmlObj.xmlRoot.site[i].xmlAttributes.index# and it contains a URL, but Im unsure how to do this in the loop. I have tried:
<cfhttp method="get" URL="#xmlObj.xmlRoot.site[i].xmlAttributes.index#" ResolveURL="yes"></cfhttp> but this does not work . How can I achieve this? Here is my code: <cfhttp method="get" URL="http://localhost:8500/Project/template.xml" ResolveURL="yes"></cfhttp> <cfset xmlString = cfhttp.fileContent /> <cfset xmlObj = xmlParse( xmlString ) /> <cfoutput> <cfloop from="1" to="#arrayLen( xmlObj.xmlRoot.xmlChildren )#" index="i"> <p> #xmlObj.xmlRoot.site[i].xmlAttributes.index#<br /> #xmlObj.xmlRoot.site[i].parse[1].xmlAttributes.re# <!---#xmlObj.xmlRoot.site[i].parse["detail-page-parsers"].xmlAttributes.re#</p>---> </cfloop> </cfoutput> |
|
#2
|
|||
|
|||
|
First you don't need to use matching tags for CFHTTP unless you're including child tags like CFHTTPPARAM. Do this:
<cfhttp method="get" URL="#xmlObj.xmlRoot.site[i].xmlAttributes.index#" ResolveURL="yes" /> Beyond that I can't tell what you are asking for. What is the acutal problem? Is the CFHTTP call generating an error? If the problem is that you're getting back XML and you aren't sure how to loop over it, just dump it <cfdump var="#xmlObj#">
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Kiteless,
I have made changes to the code I listed previously. However the problem is my output is the string URL with the message "connection failure" displayed underneath it. Here is my code: <cfset xmlString = cfhttp.fileContent /> <cfset xmlObj = xmlParse( xmlString ) /> <cfoutput> <cfloop from="1" to="#arrayLen( xmlObj.xmlRoot.xmlChildren )#" index="i"> <p> #xmlObj.xmlRoot.site[i].xmlAttributes.index#<br /> <cfhttp method="get" URL="xmlObj.xmlRoot.site[i].xmlAttributes.index" ResolveURL="yes"> #cfhttp.FileContent# parsers"].xmlAttributes.re#</p>---> </cfloop> </cfoutput> |
|
#4
|
|||
|
|||
|
Can you take each of those URLs and manually use them in a CFHTTP call? Do they work then? You could try using trim() to trim any extra whitespace around the variable holding the URL.
|
|
#5
|
|||
|
|||
|
Ive done manual cfhttp requests on all three sites and they all return the pages without problems.
Ive used Trim in the cfhttp request: <cfhttp method="get" URL="Trim(xmlObj.xmlRoot.site[i].xmlAttributes.index)" ResolveURL="yes"> Is this the correct syntax? It still returned a "connection failure" for all three. Could it be down to the fact that I am cfhttp'ing all three sites in the loop? |
|
#6
|
|||
|
|||
|
Are you forgetting the pound signs?
<cfhttp method="get" URL="#Trim(xmlObj.xmlRoot.site[i].xmlAttributes.index)#" ResolveURL="yes"> |
|
#7
|
|||
|
|||
|
Indeed I am. Problem solved. Much appreciated
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Performing a cfhttp on a returned string?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|