How to create a struct from an XML?
hi,
i qa , need create struct xml generated post in front end. have fetched xml generated using firebug. need pass struct variable , use testing purpose.
please can help?
coldfusion makes easy you. make cfhttp call retrieve xml document.
<cfhttp url="url.to.your.xml" method="post" timeout="10">
<!--- include necessary <cfhttpparam /> tags here --->
</cfhttp>
that call store xml document in variable you; named "cfhttp" unless specify otherwise.
next check success before trying parse xml. here pseudo code you.
<cfif find("200",cfhttp.statuscode)> <!--- check http call successful --->
<cfif isxml(cfhttp.filecontent)> <!--- check response valid xml format --->
<cfset soapresponse=xmlparse(cfhttp.filecontent) /> <!--- convert xml text xml document object --->
<cfdump var="#soapresponse#" /> <!--- dump xml document object --->
<!--- @ point have xml object can use things xmlsearch on (and other xml functions) --->
<!--- xmlsearch uses xpath language expression search xml document object --->
<cfelse>
<!--- response not xml --->
</cfif>
<cfelse>
<!--- http call failed --->
</cfif>
hope helps.
More discussions in ColdFusion
adobe
Comments
Post a Comment