XML - Load node data by attribute value

0 favourites
  • 2 posts
From the Asset Store
Node Downloader is a plugin for download file for Construct 3 and construct 2 game engine
  • 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 attribute.

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

    MyXML.StringValue("/ss/gms/g[@eid=' & SOME_ID & ']/node()")[/code:223tt4c6]
    However, this does not give me anything. How can I just get a node value based on an attribute?
    <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"/>
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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").

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)