•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ColdFusion section within the Web Development category of DaniWeb, a massive community of 392,082 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,973 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ColdFusion advertiser:
Views: 2746 | Replies: 2
![]() |
| |
•
•
Join Date: Dec 2006
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
This is My problem:
I receive datas from an xml Feed and I always worked in this way:
<cftry>
<!--- fetch data from web service --->
<cfhttp url="http://www............. method="get" charset="utf-8"/>
<cfset xmldata = cfhttp.fileContent>
<cftry>
<!--- extract data from XML document and convert to query --->
<cfset lstColumns = "KH,NH,KC,NC,KD,ND,KS,NS,KL,NL,KZ,NZ,LR"/>
<cfset q2 = queryNew(lstColumns)/>
<!--- <cfif isXml(cfhttp.fileContent)> avialable in CF7 only --->
<cfset xmlObject = xmlParse(xmldata)/>
<cfloop index="i" from="1" to="#arrayLen(xmlObject["ArrayOfHotelRoom"].xmlChildren)#">
<cfset queryAddRow(q2,1)/>
<cfloop index="ii" list="#lstColumns#">
<cfset querySetCell(q2,ii,xmlObject["ArrayOfHotelRoom"].xmlChildren[i][ii].xmlText)/>
</cfloop>
</cfloop>
<!--- </cfif> --->
<cfcatch type="any"> <!--- any errors return empty result set --->
<cfset q2 = queryNew(lstColumns)/>
</cfcatch>
</cftry>
<cfcatch type="any">
<cfoutput>There has been an internal problem. Please try again later</cfoutput>
<cfexit>
</cfcatch>
</cftry>
<!--- use QoQ to filter by hotel name --->
<cfquery name="q" dbtype="query">
select * from q2
where SH = 'A' <!--- only show available hotels --->
</cfquery>
NOW THE PROBLEM IS THAT I NEED NOW TO IMPROVE MY SYSTEM USING A NEW VERSION OF THE XML CATALOGUE THAT NOW INCLUDE XML.CHILDREN:
THE NEW XML:
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfHotelRoom xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/xml/xmlService">
<HotelRoom>
<KH>717</KH>
<NH>Acanto Suites & Lounge</NH>
<KC>PDC</KC>
<NC>Playa del Carmen</NC>
<KD>16</KD>
<ND>Playa del Carmen</ND>
<KS>7E</KS>
<NS>Special Category</NS>
<KL>CENT</KL>
<NL>City</NL>
<KZ>1</KZ>
<NZ>The Yucatan Peninsula</NZ>
<LR>132.5000</LR>
<Rooms>
<RoomType>
<KR>VLLBR1</KR>
<NR>One Bedroom Villa</NR>
<MP>RO</MP>
<RR>132.5</RR>
<IP>0</IP>
<IL>0</IL>
<IN>0</IN>
<IF>0</IF>
<PH>0</PH>
<SH>A</SH>
</RoomType>
</Rooms>
</HotelRoom>
AS YOU SEE AFTER "LR" NOW I FIND OTHERS CHILDREN AND I DO NOT HOW TO REDUCE MY NEW XML TO QUERY
Thank You
Andrea
This is My problem:
I receive datas from an xml Feed and I always worked in this way:
<cftry>
<!--- fetch data from web service --->
<cfhttp url="http://www............. method="get" charset="utf-8"/>
<cfset xmldata = cfhttp.fileContent>
<cftry>
<!--- extract data from XML document and convert to query --->
<cfset lstColumns = "KH,NH,KC,NC,KD,ND,KS,NS,KL,NL,KZ,NZ,LR"/>
<cfset q2 = queryNew(lstColumns)/>
<!--- <cfif isXml(cfhttp.fileContent)> avialable in CF7 only --->
<cfset xmlObject = xmlParse(xmldata)/>
<cfloop index="i" from="1" to="#arrayLen(xmlObject["ArrayOfHotelRoom"].xmlChildren)#">
<cfset queryAddRow(q2,1)/>
<cfloop index="ii" list="#lstColumns#">
<cfset querySetCell(q2,ii,xmlObject["ArrayOfHotelRoom"].xmlChildren[i][ii].xmlText)/>
</cfloop>
</cfloop>
<!--- </cfif> --->
<cfcatch type="any"> <!--- any errors return empty result set --->
<cfset q2 = queryNew(lstColumns)/>
</cfcatch>
</cftry>
<cfcatch type="any">
<cfoutput>There has been an internal problem. Please try again later</cfoutput>
<cfexit>
</cfcatch>
</cftry>
<!--- use QoQ to filter by hotel name --->
<cfquery name="q" dbtype="query">
select * from q2
where SH = 'A' <!--- only show available hotels --->
</cfquery>
NOW THE PROBLEM IS THAT I NEED NOW TO IMPROVE MY SYSTEM USING A NEW VERSION OF THE XML CATALOGUE THAT NOW INCLUDE XML.CHILDREN:
THE NEW XML:
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfHotelRoom xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/xml/xmlService">
<HotelRoom>
<KH>717</KH>
<NH>Acanto Suites & Lounge</NH>
<KC>PDC</KC>
<NC>Playa del Carmen</NC>
<KD>16</KD>
<ND>Playa del Carmen</ND>
<KS>7E</KS>
<NS>Special Category</NS>
<KL>CENT</KL>
<NL>City</NL>
<KZ>1</KZ>
<NZ>The Yucatan Peninsula</NZ>
<LR>132.5000</LR>
<Rooms>
<RoomType>
<KR>VLLBR1</KR>
<NR>One Bedroom Villa</NR>
<MP>RO</MP>
<RR>132.5</RR>
<IP>0</IP>
<IL>0</IL>
<IN>0</IN>
<IF>0</IF>
<PH>0</PH>
<SH>A</SH>
</RoomType>
</Rooms>
</HotelRoom>
AS YOU SEE AFTER "LR" NOW I FIND OTHERS CHILDREN AND I DO NOT HOW TO REDUCE MY NEW XML TO QUERY
Thank You
Andrea
•
•
Join Date: Jan 2008
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Hi
Reply if this works (You need to replace your code's relevant portion with this)
Reply if this works (You need to replace your code's relevant portion with this)
<!--- extract data from XML document and convert to query ---> <cfset lstColumns = "KH,NH,KC,NC,KD,ND,KS,NS,KL,NL,KZ,NZ,LR,KR,NR,MP,RR,IP,IL,IN,IF,PH,SH"/> <cfset q2 = queryNew(lstColumns)/> <!--- <cfif isXml(cfhttp.fileContent)> avialable in CF7 only ---> <cfset xmlObject = xmlParse(xmldata)/> <cfloop index="i" from="1" to='#arrayLen(xmlObject["ArrayOfHotelRoom"].xmlChildren)#'> <cfset queryAddRow(q2,1)/> <cfset iii = 0> <cfloop index="ii" list="#lstColumns#"> <cfif iii lt 13> <cfset querySetCell(q2,ii,xmlObject["ArrayOfHotelRoom"].xmlChildren[i][ii].xmlText)/> <cfelse> <cfset querySetCell(q2,ii,xmlObject["ArrayOfHotelRoom"].xmlChildren[i].xmlChildren[14].xmlChildren[1].xmlChildren[iii-12].xmlText)/> </cfif> <cfset iii = iii + 1> </cfloop> </cfloop>
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ColdFusion Marketplace
- sql query problem with MS Access and C# (C#)
- PHP + WebDAV (PHP)
- What exactly is xml? (RSS, Web Services and SOAP)
- Asp+xml+mssql (ASP)
- XML and hyperlink as one of the data (RSS, Web Services and SOAP)
- Retrieve Contacts from Exchange Public Folder (VB.NET)
- Parse XML from ASP!!! (ASP)
- required technical guidence for Struts and XML (Java)
Other Threads in the ColdFusion Forum
- Previous Thread: How to highlight duplicate values
- Next Thread: CFHTTP CFLOOP and unique variable


Hybrid Mode