http://www.developer.com/xml/article.php/1560361

Sorting could be accomplished by using an array sort

http://www.adobe.com/livedocs/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000355.htm

On Sat, Jan 15, 2011 at 1:55 PM, Steve Ross <nowhid...@gmail.com> wrote:

> Xpath
> On Jan 15, 2011 1:53 PM, "Michael Brown" <singleconce...@gmail.com> wrote:
> > What else do u suggest?
> >
> > Sent from my mobile
> >
> > On Jan 15, 2011, at 1:22 PM, Steve Ross <nowhid...@gmail.com> wrote:
> >
> >> One question, why are you converting this to a query? seems like a
> >> waste of effort.
> >>
> >> On Sat, Jan 15, 2011 at 12:58 PM, Michael Brown <
> singleconce...@gmail.com
> >> > wrote:
> >> Ajas,
> >>
> >> Thanks a million, may the code Gods continue to bless you!
> >>
> >> On Sat, Jan 15, 2011 at 12:22 PM, Ajas Mohammed <ajash...@gmail.com>
> >> wrote:
> >> ok, the problem is xmlsize which is set to 1, thats why you get one
> >> result set.
> >>
> >> Here is what I used xmlsize =
> >> (xmlfile.HotelAvailabilityListResults..XmlAttributes.size); //
> >> HotelAvailabilityListResults is the parent tree
> >>
> >> Full code here. FYI, the valueadds is not available in all elements
> >> so that will throw error. I have commented that line.
> >>
> >> Also, line 15 16 were giving errors so i had to modify little bit.
> >>
> >> working code
> >>
> >> <cfhttp url="
> http://merchandising.expediaaffiliate.com/campaign/?campaignId=5409&cid=311009
> >> " method="GET">
> >>
> >> <cfscript>
> >> xmlfile = xmlparse(cfhttp.filecontent); //Parses the XML
> >> xmlsize =
> >> (xmlfile.HotelAvailabilityListResults.XmlAttributes.size); //
> >> HotelAvailabilityListResults is the parent tree
> >>
> >> xmlqry = QueryNew("Hotelid, name, city, promodescription,
> >> valueadds, displayroomrate"); //Sets a query for output
> >> QueryAddRow(xmlqry,xmlsize);
> >>
> >> for(a=1;a LTE xmlsize;a=a+1) {
> >> //QuerySetCell
> >> (xmlqry,"hotelid",xmlfile.HotelAvailabilityListResults.hotel
> >> [a].xmlAttributes.hotelid,a);
> >> //QuerySetCell
> >> (xmlqry,"hotelid",xmlfile.HotelAvailabilityListResults.hotel
> >> [a].hotelid.xmlText,a);
> >> //xmlfile.Tutorials.TutorialID[a].Title.xmlText gets the
> >> text of the title for the current tutorial (xmlText)
> >> QuerySetCell
> >> (xmlqry,"name",xmlfile.HotelAvailabilityListResults.hotel
> >> [a].name.xmlText,a);
> >> QuerySetCell
> >> (xmlqry,"city",xmlfile.HotelAvailabilityListResults.hotel
> >> [a].city.xmlText,a);
> >> QuerySetCell
> >> (xmlqry,"promodescription",xmlfile.HotelAvailabilityListResults.hotel
> >> [a].HotelProperty.promodescription.xmlText,a);
> >> //QuerySetCell
> >> (xmlqry,"valueadds",xmlfile.HotelAvailabilityListResults.hotel
> >> [a].HotelProperty.valueadds.xmlText,a);
> >>
> >> //QuerySetCell
> >> (xmlqry,
> >> "displayroomrate"
> >> ,xmlfile.HotelAvailabilityListResults.hotel.HotelProperty
> >> [a].xmlAttributes.id,a);
> >> //xmlfile.Tutorials.TutorialID[a].xmlAttributes.id gets the
> >> value of the attribute in the tag
> >> }
> >> </cfscript>
> >>
> >>
> >> <cfdump var = "#xmlsize#">
> >>
> >> <cfdump var = "#xmlqry#">
> >>
> >>
> >> <cfquery name="tutorials" dbtype="query">
> >> SELECT *
> >> FROM xmlqry
> >> ORDER BY hotelid DESC
> >> </cfquery>
> >>
> >>
> >> <cfoutput query="tutorials">
> >> #name# #promodescription#
> >> <br><br>
> >> </cfoutput>
> >>
> >> hope that helps. :-)
> >> <Ajas Mohammed />
> >> http://ajashadi.blogspot.com
> >> We cannot become what we need to be, remaining what we are.
> >> No matter what, find a way. Because thats what winners do.
> >> You can't improve what you don't measure.
> >> Quality is never an accident; it is always the result of high
> >> intention, sincere effort, intelligent direction and skillful
> >> execution; it represents the wise choice of many alternatives.
> >>
> >>
> >>
> >> On Sat, Jan 15, 2011 at 10:57 AM, Michael Brown <
> singleconce...@gmail.com
> >> > wrote:
> >> Hey folks,
> >>
> >> Stuck on trying to get an XML query to display more than one
> >> record. Can't figure out what I'm doing wrong. There are 5 records
> >> in the file. The code is listed below, any suggestions would be
> >> helpful.
> >>
> >> Thanks
> >>
> >> <cfhttp url="
> http://merchandising.expediaaffiliate.com/campaign/?campaignId=5409&cid=311009
> >> " method="GET">
> >>
> >> <cfscript>
> >> xmlfile = xmlparse(cfhttp.filecontent); //Parses the XML
> >> xmlsize = arraylen(xmlfile.HotelAvailabilityListResults); //
> >> HotelAvailabilityListResults is the parent tree
> >> xmlqry = QueryNew("Hotelid, name, city, promodescription,
> >> valueadds, displayroomrate"); //Sets a query for output
> >> QueryAddRow(xmlqry,xmlsize);
> >>
> >> for(a=1;a LTE xmlsize;a=a+1) {
> >> //QuerySetCell
> >> (xmlqry,"hotelid",xmlfile.HotelAvailabilityListResults.hotel
> >> [a].xmlAttributes.hotelid,a);
> >> //QuerySetCell
> >> (xmlqry,"hotelid",xmlfile.HotelAvailabilityListResults.hotel
> >> [a].hotelid.xmlText,a);
> >> //xmlfile.Tutorials.TutorialID[a].Title.xmlText gets the
> >> text of the title for the current tutorial (xmlText)
> >> QuerySetCell
> >> (xmlqry,"name",xmlfile.HotelAvailabilityListResults.hotel
> >> [a].name.xmlText,a);
> >> QuerySetCell
> >> (xmlqry,"city",xmlfile.HotelAvailabilityListResults.hotel
> >> [a].city.xmlText,a);
> >> QuerySetCell
> >> (xmlqry,
> >> "promodescription"
> >> ,xmlfile.HotelAvailabilityListResults.hotel.HotelProperty
> >> [a].promodescription.xmlText,a);
> >> QuerySetCell
> >> (xmlqry,
> >> "valueadds",xmlfile.HotelAvailabilityListResults.hotel.HotelProperty
> >> [a].valueadds.xmlText,a);
> >> //QuerySetCell
> >> (xmlqry,
> >> "displayroomrate"
> >> ,xmlfile.HotelAvailabilityListResults.hotel.HotelProperty
> >> [a].xmlAttributes.id,a);
> >> //xmlfile.Tutorials.TutorialID[a].xmlAttributes.id gets the
> >> value of the attribute in the tag
> >> }
> >> </cfscript>
> >>
> >> <cfquery name="tutorials" dbtype="query">
> >> SELECT *
> >> FROM xmlqry
> >> ORDER BY hotelid DESC
> >> </cfquery>
> >>
> >>
> >> <cfoutput query="tutorials">
> >> #name# #promodescription#
> >> <br><br>
> >> </cfoutput>
> >>
> >>
> >>
> >>
> >>
> >> --
> >> Steve Ross
> >> web application & interface developer
> >> http://blog.stevensross.com
> >> [mobile] (912) 344-8113
> >> [ AIM / Yahoo! : zeriumsteven ] [googleTalk : nowhiding ]
>



-- 
Steve Ross
web application & interface developer
http://blog.stevensross.com
[mobile] (912) 344-8113
[ AIM / Yahoo! : zeriumsteven ] [googleTalk : nowhiding ]

Reply via email to