Support Forum

Ask questions and get help from MobileTogether experts.
MobileTogether Product Information
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
View
Go to last post Go to first unread
jwatt222  
#1 Posted : Tuesday, February 20, 2018 10:18:32 AM(UTC)
jwatt222

Rank: Advanced Member

Groups: Registered
Joined: 5/23/2016(UTC)
Posts: 69
United States
Location: Virginia

Thanks: 11 times
I am working on a weather app with both current and a 5 day forecast. I am using a HTTP request with json because accuweather does not seem to support xml.

I need guidance on where and how to approach showing the icons for the five day forecast.

I am receiving all the data I need in the request but having an issue with loading the images for the 5 day forecast.

accuweather does not allow pulling the images through a url so I downloaded them and converted them to base64.I then loaded them into an xml file. when I make a request the icon only shows a number for the icon. Therefore I cannot use it as a source for the image.

I am sure that I am approaching this wrong but have been searching the manual and researching the internet for days. I have also asked accuweather for help but no luck there either.

To get the current weather image I can match the number to the image easily because it is only a single icon. I am using: $XML6/Weather/WeatherCurrent/weather[ @current = $HTTP2/json/item/WeatherIcon]/@image in the image source

My problem is when trying to match the 5 icons from the 5 day forecast, I can only get the first or the last which shows for all 5 images. I have tried several different approaches without success. I assume that I am leaving something out that will perform the function for every item and return the image but cannot figure out what that is.

in the image source
$XML6/Weather/WeatherForecast/weather[ @forecast = $HTTP2/json/item/WeatherIcon]/@image gets the last icon

$XML6/Weather/WeatherForecast/weather[ @forecast = $HTTP2/json/item[1]/WeatherIcon]/@image allows me to select the position but still only shows the same icon for all 5 days which is wrong.

In the designer, I have only one item in the tree structure which repeats in the request

File Attachment(s):
2018_02_21_12_13_09.jpg (305kb) downloaded 12 time(s).
AFC  
#2 Posted : Tuesday, February 20, 2018 2:55:48 PM(UTC)
AFC

Rank: Administration

Groups: Registered, Administrators
Joined: 9/15/2014(UTC)
Posts: 53
Austria

Was thanked: 8 time(s) in 8 post(s)
Hello jwatt222!

Without knowing your design (where/how do you want to show the icons), your structure ($XML6) and the accuweather structure ($HTTP2), we just can guess.

E.g. in case you want to show these images inside a table with dynamic rows, the repeating element of the table row will be the XPath context you can use.

In this case something like
Quote:
$XML6/Weather/WeatherForecast/weather[ @forecast = ./WeatherIcon]/@image

could help (if $HTTP2/json/item is the repeating element).

But as I said - just guessing, so if this does not help, we will need more information or you attach your sample here or even best: send it to our Support team, that they can look into it in detail.

By the way: did you look into our tutorials? The MobileTogether designer comes with some nice image tutorials, like Base64Images.mtd, UserSelectedImages.mtd.

Best regards,
AFC
jwatt222  
#3 Posted : Tuesday, February 20, 2018 6:00:13 PM(UTC)
jwatt222

Rank: Advanced Member

Groups: Registered
Joined: 5/23/2016(UTC)
Posts: 69
United States
Location: Virginia

Thanks: 11 times
AFC, thanks for your response. I tried pasting the required info but it exceeded the allotment for the post. I will try and load the necessary files. I have checked the manual in which I learned to encode the images to base64 and to add them to an xml file. I looked at the flags.mtd file that answered someone elses questions here on the forum but it only used a single image. It did help to get started and gave me the expression that I am using with mods. I have also added a rss news reader before that works fine but I am not pulling images there. This is the first attempt at a json based HTTP request with images. I am receiving the text data for everything with no problems.

This works fine for the single image current weather icon as the base64 image source: $XML6/Weather/WeatherCurrent/weather[ @current = $HTTP2/json/item/WeatherIcon]/@image

However a similiar expression does not work as the base64 image source for the repeating elements.

HTTP/3/json/Daily Forecast/Day/item "is" the repeating element and I am using a table with dynamic rows which includes the image for the WeatherIcon. However,

$XML6/Weather/WeatherForecast/weather[ @forecast = $HTTP3/json/DailyForecast/item/Day/Icon]/@image is only getting the last of the 5 icons and showing it for all 5 forecasted days.

$XML6/Weather/WeatherForecast/weather[ @forecast = $HTTP3/json/DailyForecast/item[1]/Day/Icon]/@image allows me to pick the posion of the repeating element but shows it for all 5 forecasted days.

I also considered a Loop, For, or Let expression but the result was the same or with item type matching errors. (I'm sure I probably screwed that up but that's why I am requesting your help.)
File Attachment(s):
Weather.xml (703kb) downloaded 12 time(s).
HTTP3.json (10kb) downloaded 12 time(s).
jwatt222 attached the following image(s):
truckersweather.PNG
truckersweather-designer.PNG
truckersweather-designer2.PNG
AFC  
#4 Posted : Wednesday, February 21, 2018 10:30:10 AM(UTC)
AFC

Rank: Administration

Groups: Registered, Administrators
Joined: 9/15/2014(UTC)
Posts: 53
Austria

Was thanked: 8 time(s) in 8 post(s)
Hello jwatt222,

You again use the same absolute XPath expressions from your first post but not the relative context node.

Attached is a small sample which reads 5 different forecasts by using
Quote:
$XML6/Weather/WeatherForecast/weather[ @forecast = current()/Day/Icon ]/@image

for the image URL.

Best regards,
AFC
File Attachment(s):
HTTP3.json (28kb) downloaded 11 time(s).
Weather.xml (703kb) downloaded 11 time(s).
RepeatingImages.mtd (44kb) downloaded 11 time(s).
AFC attached the following image(s):
RepeatingImages.png
thanks 1 user thanked AFC for this useful post.
jwatt222 on 2/21/2018(UTC)
jwatt222  
#5 Posted : Wednesday, February 21, 2018 6:22:39 PM(UTC)
jwatt222

Rank: Advanced Member

Groups: Registered
Joined: 5/23/2016(UTC)
Posts: 69
United States
Location: Virginia

Thanks: 11 times
You are AWESOME! Working fine. See attached image from my tablet.
File Attachment(s):
2018_02_21_12_13_09.jpg (305kb) downloaded 24 time(s).
jwatt222  
#6 Posted : Wednesday, February 21, 2018 6:29:42 PM(UTC)
jwatt222

Rank: Advanced Member

Groups: Registered
Joined: 5/23/2016(UTC)
Posts: 69
United States
Location: Virginia

Thanks: 11 times
Thanks so much for your help!
Users browsing this topic
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.