Weather app with openweather

Hello.
I am creating an amateur app with the openweather API...the free one gives me both current conditions and forecasts every 3 hours for the next 5 days.
Up to the current conditions all ok, when I try to enter the forecasts I have a problem. One forecast looks like this:

<weatherdata>
<location>
<name>Municipality of Bari</name>
<type/>
<country>IT</country>
<timezone>7200</timezone>
<location altitude="0" latitude="41.1177" longitude="16.8512" geobase="geonames" geobaseid="6542001"/>
</location>
<credit/>
<meta>
<lastupdate/>
<calctime>0</calctime>
<nextupdate/>
</meta>
<sun rise="2022-08-16T04:03:00" set="2022-08-16T17:51:07"/>
<forecast>
<time from="2022-08-16T15:00:00" to="2022-08-16T18:00:00">
<symbol number="500" name="light rain" var="10n"/>
<precipitation probability="0.26" unit="3h" value="0.53" type="rain"/>
<windDirection deg="119" code="ESE" name="East-southeast"/>
<windSpeed mps="0.75" unit="m/s" name="Calm"/>
<windGust gust="1.4" unit="m/s"/>
<temperature unit="celsius" value="30.87" min="29.62" max="30.87"/>
<feels_like value="32.21" unit="celsius"/>
<pressure unit="hPa" value="1011"/>
<humidity value="49" unit="%"/>
<clouds value="cielo sereno" all="8" unit="%"/>
<visibility value="10000"/>
</time>
<time from="2022-08-16T18:00:00" to="2022-08-16T21:00:00">
<symbol number="801" name="poche nuvole" var="02n"/>
<precipitation probability="0.06"/>
<windDirection deg="354" code="N" name="North"/>
<windSpeed mps="0.66" unit="m/s" name="Calm"/>
<windGust gust="1.82" unit="m/s"/>
<temperature unit="celsius" value="29.7" min="28.8" max="29.7"/>
<feels_like value="31.39" unit="celsius"/>
<pressure unit="hPa" value="1011"/>
<humidity value="55" unit="%"/>
<clouds value="poche nuvole" all="11" unit="%"/>
<visibility value="10000"/>
</time>
</forecast>
</weatherdata>

(formatted by Taifun)

I'm using XML format, and as you can see the file consists of two "times" that I can't split. I tried to do it this way, but it gives me an error:

How can I make it read only the first "time," then the second and so on?

Show us your query and the raw responseContent.


here you can find all the code I made

Here, on the other hand, is the xml api that I am using:
https://api.openweathermap.org/data/2.5/forecast?q=bari&APPID=f5b73efa0dc01f5045e017d4bf95db7f&units=metric&lang=it&mode=xml

when in "Lb_condition2" I call the XML2 extract and proceed with the list "weatherdata,forecast,time(1),symbol" I get the error "The operation lookup in pairs cannot accept the arguments: , [symbol], [not found], [not found]."

There is no subscript notation in XML parsing.

It should be ...,time,1,... and you XML parsing procedure(s) should check each key along the path for whether or not it is a number.
For a number in the path, that number should be used as an index in a select item n from list block, instead of a lookup in pairs block.

<weatherdata>
<location>
<name>Comune di Bari</name>
<type/>
<country>IT</country>
<timezone>7200</timezone>
<location altitude="0" latitude="41.1177" longitude="16.8512" geobase="geonames" geobaseid="6542001"/>
</location>
<credit/>
<meta>
<lastupdate/>
<calctime>0</calctime>
<nextupdate/>
</meta>
<sun rise="2022-08-16T04:03:00" set="2022-08-16T17:51:07"/>
<forecast>
<time from="2022-08-16T15:00:00" to="2022-08-16T18:00:00">
<symbol number="500" name="pioggia leggera" var="10n"/>
<precipitation probability="0.26" unit="3h" value="0.53" type="rain"/>
<windDirection deg="119" code="ESE" name="East-southeast"/>
<windSpeed mps="0.75" unit="m/s" name="Calm"/>
<windGust gust="1.4" unit="m/s"/>
<temperature unit="celsius" value="30.61" min="29.62" max="30.61"/>
<feels_like value="31.98" unit="celsius"/>
<pressure unit="hPa" value="1011"/>
<humidity value="50" unit="%"/>
<clouds value="cielo sereno" all="0" unit="%"/>
<visibility value="10000"/>
</time>
<time from="2022-08-16T18:00:00" to="2022-08-16T21:00:00">
<symbol number="800" name="cielo sereno" var="01n"/>
<precipitation probability="0.06"/>
<windDirection deg="354" code="N" name="North"/>
<windSpeed mps="0.66" unit="m/s" name="Calm"/>
<windGust gust="1.82" unit="m/s"/>
<temperature unit="celsius" value="30.01" min="28.8" max="30.01"/>
<feels_like value="31.56" unit="celsius"/>
<pressure unit="hPa" value="1011"/>
<humidity value="53" unit="%"/>
<clouds value="cielo sereno" all="6" unit="%"/>
<visibility value="10000"/>
</time>
<time from="2022-08-16T21:00:00" to="2022-08-17T00:00:00">
<symbol number="800" name="cielo sereno" var="01n"/>
<precipitation probability="0.04"/>
<windDirection deg="332" code="NNW" name="North-northwest"/>
<windSpeed mps="1" unit="m/s" name="Calm"/>
<windGust gust="1.69" unit="m/s"/>
<temperature unit="celsius" value="28.69" min="27.73" max="28.69"/>
<feels_like value="30.66" unit="celsius"/>
<pressure unit="hPa" value="1012"/>
<humidity value="61" unit="%"/>
<clouds value="cielo sereno" all="6" unit="%"/>
<visibility value="10000"/>
</time>

For specific blocks, export a .aia file and post it here.

Here is a sample XML explorer app you can try ...

Also see samples in

With KIO4_DecoJson extension:

borrar_foreweather.aia (582.6 KB)

Another way

<time space

The problem is that I have the same variable (time) repeated several times... that's why I had tried to put time(1) to extrapolate the data included in the first time...

While I want to take, from this long file (consisting of 40 "times"), the variables of the first time (for example, temperature, wind and conditions; then take the same variables of the second time (as you see the time changes) and so on.

that's not right

Have you seen the example with the KIO4_DecoJson extension?
Through a loop you can get all the temperatures, humidity,...

It can also be done with the second example that I have put, but it is easier with the first.

sorry for the delay. i used the KIO4_DecoJson extension, but i have problems with the icon and the "". I'll show you an example.

where there is next 3h etc., you can see the inverted commas (''), whereas I would like to get it all as in the first part (so without the '' and with the weather icon).

I think the easiest way is using the Text block,
replace all text
segment: "
replacement:

yes I had solved it, thank you very much

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.