Extract pair data from XML text

Hi,

In appinventor reference
http://ai2.appinventor.mit.edu/reference/other/xml.html

extract pair data from

(tem_f 68.2)

using 'look up in pairs key "temp_f"...

and I followed reference then got similar XML text

temperature value="-4.91" min="-7" max="-4" unit="celsius"/>

then tried to use 'look up in pairs key "temperature value"

and I got 'not found' as result.
Thx in advance for any help...

Cn you please post an example of your XML?

<city id="1835848" name="Seoul">
<coord lon="126.98" lat="37.57"/>
<country>KR</country>
<timezone>32400</timezone>
<sun rise="2021-01-02T22:47:06" set="2021-01-03T08:25:28"/>
</city>
<temperature value="-6.61" min="-8" max="-6" unit="celsius"/>
<feels_like value="-12.21" unit="celsius"/>
<humidity value="41" unit="%"/>
<pressure value="1033" unit="hPa"/>
<wind>
<speed value="3" unit="m/s" name="Light breeze"/>
<gusts/>
<direction value="304" code="NW" name="Northwest"/>
</wind>
<clouds value="1" name="맑음"/>
<visibility value="10000"/>
<precipitation mode="no"/>
<weather number="800" value="맑음" icon="01n"/>
<lastupdate value="2021-01-02T17:10:35"/>
</current>

Sorry, but this is not enough, because like this it is not well-formed XML

1 Like

Are you using openweathermap api ? If so try the following blocks

1 Like

I would abandon XML parsing and instead use the Taifun parse procedure with
start <temperature value="
and end "

1 Like

Thx, It worked.

I was trying to using XML text to check value available.
But using 'list of pairs to dictionary' more complicated the code than using 'split text'. ha ha!
:frowning:

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