XML - Load node data by attribute value

Get help using Construct 2

Post » Mon Dec 21, 2015 2:56 am

I am a web developer just learning how to use Construct 2. One thing I am exploring right now is dealing with XML data.I am working with this NFL game data just as something that's already generated. As you can see, it only uses nodes and attributes, there is no text values for the nodes.

(EDIT - it seems it won't let me post the URL to the XML feed -
nfl DOT com/liveupdate/scorestrip/ss.xml

Now I would like to be able to load one of the <g> nodes based on @eid attribute.

It seems based on some sparse info I have found, that I should be able to use:

Code: Select all
MyXML.StringValue("/ss/gms/g[@eid=' & SOME_ID & ']/node()")

However, this does not give me anything. How can I just get a node value based on an attribute?

Code: Select all
<gms w="15" y="2015" t="R" gd="1" bph="134">
<g eid="2015121700" gsis="56711" d="Thu" t="8:25" q="F" h="STL" hnn="rams" hs="31" v="TB" vnn="buccaneers" vs="23" rz="0" ga="" gt="REG"/>
<g eid="2015121900" gsis="56712" d="Sat" t="8:25" q="F" h="DAL" hnn="cowboys" hs="16" v="NYJ" vnn="jets" vs="19" rz="0" ga="" gt="REG"/>
<g eid="2015122006" gsis="56713" d="Sun" t="1:00" q="F" h="BAL" hnn="ravens" hs="14" v="KC" vnn="chiefs" vs="34" rz="0" ga="" gt="REG"/>
<g eid="2015122004" gsis="56714" d="Sun" t="1:00" q="F" h="IND" hnn="colts" hs="10" v="HOU" vnn="texans" vs="16" rz="0" ga="" gt="REG"/>
<g eid="2015122003" gsis="56715" d="Sun" t="1:00" q="F" h="JAC" hnn="jaguars" hs="17" v="ATL" vnn="falcons" vs="23" rz="0" ga="" gt="REG"/>
<g eid="2015122002" gsis="56716" d="Sun" t="1:00" q="F" h="MIN" hnn="vikings" hs="38" v="CHI" vnn="bears" vs="17" rz="0" ga="" gt="REG"/>
<g eid="2015122005" gsis="56717" d="Sun" t="1:00" q="F" h="NE" hnn="patriots" hs="33" v="TEN" vnn="titans" vs="16" rz="0" ga="" gt="REG"/>
<g eid="2015122000" gsis="56718" d="Sun" t="1:00" q="F" h="NYG" hnn="giants" hs="35" v="CAR" vnn="panthers" vs="38" rz="0" ga="" gt="REG"/>
<g eid="2015122007" gsis="56720" d="Sun" t="1:00" q="F" h="WAS" hnn="redskins" hs="35" v="BUF" vnn="bills" vs="25" rz="0" ga="" gt="REG"/>
<g eid="2015122009" gsis="56721" d="Sun" t="4:05" q="F" h="OAK" hnn="raiders" hs="20" v="GB" vnn="packers" vs="30" rz="0" ga="" gt="REG"/>
<g eid="2015122008" gsis="56722" d="Sun" t="4:05" q="F" h="SEA" hnn="seahawks" hs="30" v="CLE" vnn="browns" vs="13" rz="0" ga="" gt="REG"/>
<g eid="2015122010" gsis="56723" d="Sun" t="4:25" q="F" h="PIT" hnn="steelers" hs="34" v="DEN" vnn="broncos" vs="27" rz="0" ga="" gt="REG"/>
<g eid="2015122011" gsis="56724" d="Sun" t="4:25" q="F" h="SD" hnn="chargers" hs="30" v="MIA" vnn="dolphins" vs="14" rz="0" ga="" gt="REG"/>
<g eid="2015122012" gsis="56725" d="Sun" t="4:25" q="F" h="SF" hnn="49ers" hs="14" v="CIN" vnn="bengals" vs="24" rz="0" ga="" gt="REG"/>
<g eid="2015122001" gsis="56719" d="Sun" t="8:30" q="1" k="05:17" h="PHI" hnn="eagles" hs="3" v="ARI" vnn="cardinals" vs="7" p="ARI" rz="0" ga="" gt="REG"/>
<g eid="2015122100" gsis="56726" d="Mon" t="8:30" q="P" h="NO" hnn="saints" hs="0" v="DET" vnn="lions" vs="0" rz="0" ga="" gt="REG"/>
Posts: 2
Reputation: 204

Post » Mon Dec 21, 2015 10:25 am

I think that you always need a XML Foreach node condition. Inside it you can check any node attribute. Like XML.StringValue("@eid") = "SOME_ID".
Then in the action you can retrieve another attribute from that node, XML.StringValue("@gsis").
Posts: 15
Reputation: 589

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests