Expand|Select|Wrap|Line Numbers
- <cfcomponent>
- <cffunction name="getDetails"
- access="remote"
- returntype="string"
- output="no" >
- <cfargument name="inputString" type="string" required="yes">
- <cfset xmlFileAddress = Expandpath("XMLcoursework.xml")>
- <cffile action="READ" file="#xmlFileAddress#" variable="xmlObject">
- <cfset xmlDOM = "XMLParse(#xmlObject#)">
- <cfset scoreEXP = "/MiniLeagueTeams/MATCHES/match[@name='inputString']/score">
- <cfset score = XmlSearch(xmlDOM, scoreEXP)>
- <cfset returnval = "test">
- <cfreturn returnval>
- </cffunction>
- </cfcomponent>
Expand|Select|Wrap|Line Numbers
- <?xml version="1.0" encoding="UTF-8"?>
- <MiniLeagueTeams xmlns="w3" xsi:schemaLocation="w3 file:///C:/ColdFusion8/wwwroot/SCHEMAcoursework.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <TEAMS>
- <team id="1">
- <teamName>Chelsea</teamName>
- <gamesPlayed>6</gamesPlayed>
- <won>1</won>
- <drawn>1</drawn>
- <lost>0</lost>
- <gf>1</gf>
- <ga>1</ga>
- <GFminusGA>2</GFminusGA>
- <points>722</points>
- <yellowCards>
- <playerName>player1</playerName>
- <playerName>player2</playerName>
- </yellowCards>
- <redCards>
- <playerName>player1</playerName>
- </redCards>
- </team>
- </TEAMS>
- <MATCHES>
- <match name="Chelsea VS Valencia">
- <home>
- <teamName>Chelsea</teamName>
- <goals>
- <goalScorer>Player1</goalScorer>
- </goals>
- </home>
- <away>
- <teamName>Valencia</teamName>
- <goals>
- <goalScorer>Player2</goalScorer>
- <goalScorer>Player3</goalScorer>
- </goals>
- </away>
- <score>2 - 1</score>
- <winner>Valencia</winner>
- </match>
- </MATCHES>
- </MiniLeagueTeams>
Expand|Select|Wrap|Line Numbers
- <cfset xmlFile = Expandpath("XMLcoursework.xml")>
- <cffile action="READ" file="#xmlFile#" variable ="xmlObject">
- <cfset xmlDOM = XMLParse(xmlObject)>
- <cfset noMatches = ArrayLen(xmlDOM.XMLROOT.XMLChildren[2].XmlChildren)>
- <cfloop from="1" to="#noMatches#" index="i">
- <cfset currentMatch = xmlDOM.XMLRoot.XmlChildren[2].XmlChildren[i]>
- <cfset matchName = currentMatch.XmlAttributes.name>
- <cfif #matchName# EQ "Chelsea VS Valencia">
- <cfset score= currentMatch["score"].XmlText>
- <cfdump var="#score#"/>
- </cfif>
- </cfloop>