coldfusion + xml get node according to date -
xml trickiness. i'm trying isolate node sports "match" in progress or next upcoming match.
thisschedulexml:
<data> <sport type="union"> <schedules> <competition id="48" name="sr" type="union" group=""> <match id="1684" round="week 1" previewarticleid="" matchreportarticleid="" status="upcoming" alternateid="1"> <matchdate startdatelocal="2011-02-18 19:35:00" dayname="fri" shortdate="18-feb">2011-02-18 19:35:00</matchdate> <venue id="30" timezoneid="nzdt" gmtminutes="780" venue="westpac stadium" location="wellington">westpac stadium, wellington</venue> <hometeam id="8" alternateid="428">hurricanes</hometeam> <awayteam id="7" alternateid="427">highlanders</awayteam> </match> <match id="1685" round="week 1" previewarticleid="" matchreportarticleid="" status="upcoming" alternateid="2"> <matchdate startdatelocal="2011-02-11 19:40:00" dayname="fri" shortdate="18-feb">2011-02-11 19:40:00</matchdate> <venue id="160" timezoneid="aedt" gmtminutes="660" venue="aami park" location="melbourne">aami park, melbourne</venue> <hometeam id="76" alternateid="0">rebels</hometeam> <awayteam id="12" alternateid="422">waratahs</awayteam> </match> .. more matches </competition> ... more competitions </schedules> </sport> </data>
any in right direction appreciated. have thought along these line:
<cfset currentmatchnode = xmlsearch(thisschedulexml,"/sportaldata/sport/schedules/match/matchdate[@startlocaldate current otherwise next upcoming one]")>
i couldn't find way match on date in xpath. maybe else can that. however, in past we've dealt in cf, using loop. example:
<cfset nodes = xmlsearch(x, "/data/sport/schedules/competition/match") /> <cfset found = false /> <cfloop array="#nodes#" index="match"> <!--- check see if match on or in future ---> <cfif match["matchdate"].xmltext gte now()> <cfdump var="#match#" /> <cfset found = true /> </cfif> <!--- output first ---> <cfif found> <cfbreak /> </cfif> </cfloop>
that print match
node of first match coming up. hope helps in right direction.
Comments
Post a Comment