How do I - Parse speciffic data from an xml or json

0 favourites
  • 4 posts
From the Asset Store
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • Hi there. I have an XML file which was provided to me. I need to parse speciffic data and send it to my elements. It's a weather app. I can easily convert the xml to json if needed however I rather keep it in its original format for practical purposes (the prvider always sends it in xml I just wanna swap files to update the info)

    Here's a sample of the node I need to access the data from:

    <Day DayNum="2" DayOfWk="Viernes" ValidDateUtc="6/6/2014 12:00:00 AM" ValidDateLocal="6/6/2014 7:00:00 AM" HiTempF="75" LoTempF="59" HiTempC="24" LoTempC="15" ShortPhrase="Parcialmente nublado" PhraseDay="Parcialmente nuboso. Máximas 24C. Vientos ONO entre 15 y 25 km/h." PhraseNight="Predominantemente despejado. Mínima 15C. Vientos ONO entre 10 y 15 km/h." IconCode="66" SkyCode="30" SkyText="Parcialmente nublado" PrecipChance="20" SnowChance="0" RelHumidity="64" WndSpdMph="10" WndSpdKm="16" WndSpdKn="9" WndDirDegr="303" WndDirCardinal="ONO" CloudCoverage="60" UvIdx="8" UvDescr="Muy Alto" UvWarn="0" Sunrise="05:08:00 am" Sunset="08:18:00 pm" Moonrise="01:27:00 pm" Moonset="01:06:00 am" MoonPhase="3" MoonPhaseText="Gibosa Creciente" SkyCodeDay="30" SkyCodeNight="31" PrecipChanceDay="20" PrecipChanceNight="0" IconCodeDay="66" IconCodeNight="97" SkyTextDay="Parcialmente nublado" SkyTextNight="Despejado" RelHumidityNight="68" WndSpdMphNight="8" WndSpdKmNight="12" WndSpdKnNight="6" WndDirDegrNight="282" WndDirCardinalNight="WNW" PhraseDayC="Parcialmente nuboso. Máximas 24C. Vientos ONO entre 15 y 25 km/h." PhraseNightC="Predominantemente despejado. Mínima 15C. Vientos ONO entre 10 y 15 km/h." SnowAmtIn="0.00" SnowAmtCm="0.00" />

    My xml knowledge is rather limited at the moment and trough javascript i can make a preety list out of this however I want to be able to just grab some of this information and place it into their repository in c2.

    example:

    I want to get the attribute information from specific parts and place it into either variables or use it to change the state of a sprite.

    something like the textfield Day of the week should have the value assigned to DayOfWk="Viernes"(friday)

    If i learn to do that I can preety much do the rest of the legwork with ease I'm stuck in things that should be "simple" for people who have experience with xml but I'm not one f those yet.

    I tried usingthe xml demo included in C2 however i totally messed it up to the point of it not working at all ... (that's what coffee deprivation does )

    Any help is greatly appreciated.

  • blackhornet this looks to be just what I needed ... Thanks for the help. I'll let you know on the results as soon as i get back on my com. Thanx again for the quick and usefull response.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanx a bunch to blackhornet This is working now as needed.. now i need to get all my gears back to work.

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