Thornton Weather
Posts: 0
Joined: Thu Mar 28, 2013 5:02 pm

Newbie: Mapping and displaying XML data on a label

I freely admit I am entirely new to the mobile development arena so please forgive me is I appear to be dense. ;-) In starting to play around I wanted to read in an XML file via REST and then display data from the XML on a label.

Being a weather geek I thought a weather forecast would be a good way to get started so I configure REST to grab the XML forecast for my area.

http://forecast.weather.gov/MapClick....

All I want to do is take some of the data within – say forecast temperatures – and display them in a label. Despite my best efforts, I have not had much luck at all. If I let the service automatically create the response from the return sample, it doesn’t want to generate individual values.

I suspect I need to modify the response to properly parse these so they can be mapped but, being new at this, I am not having any luck. Any help would be greatly appreciated.

Code: Select all

 Tony 

Image

Image

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Newbie: Mapping and displaying XML data on a label

Hi,

To display all data from tag you should create Grid and place Label component inside. Then map "value" array to Grid, and "value" to Label.

As a result, there will be created as many Label components, as there are values in "value" array.
Image

Thornton Weather
Posts: 0
Joined: Thu Mar 28, 2013 5:02 pm

Newbie: Mapping and displaying XML data on a label

Very good! Thank you for the help, Katya. That works perfectly. Now a follow up question to take that a step further... How do I display just one of the values? For instance if I want to display the third one under 'minimum'? I've tried various modifications to the response but can't seem to get it right.

Thank you again!

Code: Select all

Tony
Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Newbie: Mapping and displaying XML data on a label

You should use JavaScript to search minimum and maximum value. To do this on "Data" tab open Events, choose Rest Service and create Run JavaScript action on Success event.

In JavaScript you can get temperature array using the following code:
codevar values = data.dwml.data[0].parameters.temperature[0].value;/code

Return to “Issues”