0

XML as Live Text data source

I want to use the xml feeds from weather.gov and weatherunderground.com in my presentation

http://forecast.weather.gov/MapClick.php?lat=34.212086073035955&lon=-118.2183837890625&FcstType=xml

http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=91011

 

But, I guess because they're not RSS feeds with "title" and "description" all I get in the "add live text" box is 'none'.  Is there any way to use this data?  Do I need a custom brightscript plugin?  What's the simplest way to get at the entries in this very useful feed?!

 

Ben

7 comments

  • 0
    Avatar
    JRB Technical

    My understanding is that the Live Text feature is looking for a specific format of XML file, that is not compatible with the format that is needed for Live Text.

    You might be able to write a script on your server side, that gets the weather XML and then creates a new XML file that is is the format needed.

    This thread gives you a bit more on how the live text feature and XML works:

    http://support.brightsign.biz/entries/20951306-how-does-livetext-data-work-with-xml-rss-files

    John

  • 0
    Avatar
    JRB Technical

    Sorry, it's late, and no edit after post feature turned on here (most allow a five minute window to edit after posting).

    I meant that the format used for the weather XML is not in the format that is needed by the BrightSign/BrightAuthor, which is in a specific format for the BrightSign to be able to read.

    John

  • 0
    Avatar
    JRB Technical

    If you do not find a solution on your end, I do provide weather screens via Media RSS for many BrightSign users around the world.  I have a Basic Weather package design, but I have also done several custom screens for people, where they send me a Photoshop PSD of what they are looking for, and I work with them to create a custom build off of that.  Feeds are $5 USD a month per player, plus a one time fee for the custom screens based on the amount of work for that build.  Let me know if this would be of any help.

    John

  • 0
    Avatar
    Ben Slocum

    Thanks for the offer John.  I think I'll be able to make this work though... I got this message back from support

     

    "

    Yes, you would need a plugin to parse the xml file to pull out the data you want, and to put that data into the index used by brightgauthor. You wouldn't see the entries in the preview window, but they would be filled in for you.

    You can store the parsed information in two ways, either by a named titled, that you could then use to retrieve the data, or just into the indexed data structure where each value just has a place holder starting with 1, 2, 3, etc.

    I'm attaching a sample xml file and plugin script used to pull a specific value out of the xml, and then store it so it can be used by looking up its index.

    Attachment(s)
    parser_slater-ba.brs
    slaters.xml"

    Still trying to figure it all out, but it does look possible.  When I've got it all working I'll try to remember to share on the forum for anyone else who's trying to do a similar thing.

     

    Ben

  • 0
    Avatar
    Shaun

    How did you go with this? About to have a similar project come my way have to parse xml for events with time as title and the rest as description. With some Jpeg slides.

    Might try a mrss feed as the text needs back ground image also covers me for sourcing the slides. And parse the xml for the other info.

    have attached a rough xml (no mrss script yet) 

     

     

     

     

     

     

     

     

     

  • 0
    Avatar
    Ben Slocum

    I don't know about getting the images from the xml, but with the help of Brightsign Support I was able to get the text I needed from the xml.

    I won't share the link to my WUnderground.com feed since it has my API key, but here's the content of the feed I needed data from:


    <response>
    <version>0.1</version>
    <termsofService>
    http://www.wunderground.com/weather/api/d/terms.html
    </termsofService>
    <features>
    <feature>conditions</feature>
    </features>
    <error>
    <type>unknownfeature</type>
    </error>
    <current_observation>
    <image>
    <url>
    http://icons-ak.wxug.com/graphics/wu2/logo_130x80.png
    </url>
    <title>Weather Underground</title>
    <link>http://www.wunderground.com</link>
    </image>
    <display_location>
    <full>Santa Maria, CA</full>
    <city>Santa Maria</city>
    <state>CA</state>
    <state_name>California</state_name>
    <country>US</country>
    <country_iso3166>US</country_iso3166>
    <zip>93454</zip>
    <latitude>34.87752151</latitude>
    <longitude>-120.33180237</longitude>
    <elevation>177.00000000</elevation>
    </display_location>
    <observation_location>
    <full>Righetti High School, Orcutt, California</full>
    <city>Righetti High School, Orcutt</city>
    <state>California</state>
    <country>US</country>
    <country_iso3166>US</country_iso3166>
    <latitude>34.883854</latitude>
    <longitude>-120.422493</longitude>
    <elevation>430 ft</elevation>
    </observation_location>
    <estimated></estimated>
    <station_id>KCAORCUT2</station_id>
    <observation_time>Last Updated on February 16, 8:29 AM PST</observation_time>
    <observation_time_rfc822>Sat, 16 Feb 2013 08:29:14 -0800</observation_time_rfc822>
    <observation_epoch>1361032154</observation_epoch>
    <local_time_rfc822>Sat, 16 Feb 2013 08:32:01 -0800</local_time_rfc822>
    <local_epoch>1361032321</local_epoch>
    <local_tz_short>PST</local_tz_short>
    <local_tz_long>America/Los_Angeles</local_tz_long>
    <local_tz_offset>-0800</local_tz_offset>
    <weather>Mostly Cloudy</weather>
    <temperature_string>60.2 F (15.7 C)</temperature_string>
    <temp_f>60.2</temp_f>
    <temp_c>15.7</temp_c>
    <relative_humidity>27%</relative_humidity>
    <wind_string>Calm</wind_string>
    <wind_dir>East</wind_dir>
    <wind_degrees>99</wind_degrees>
    <wind_mph>0.0</wind_mph>
    <wind_gust_mph>0</wind_gust_mph>
    <wind_kph>0.0</wind_kph>
    <wind_gust_kph>0</wind_gust_kph>
    <pressure_mb>1022</pressure_mb>
    <pressure_in>30.17</pressure_in>
    <pressure_trend>+</pressure_trend>
    <dewpoint_string>26 F (-3 C)</dewpoint_string>
    <dewpoint_f>26</dewpoint_f>
    <dewpoint_c>-3</dewpoint_c>
    <heat_index_string>NA</heat_index_string>
    <heat_index_f>NA</heat_index_f>
    <heat_index_c>NA</heat_index_c>
    <windchill_string>NA</windchill_string>
    <windchill_f>NA</windchill_f>
    <windchill_c>NA</windchill_c>
    <feelslike_string>60.2 F (15.7 C)</feelslike_string>
    <feelslike_f>60.2</feelslike_f>
    <feelslike_c>15.7</feelslike_c>
    <visibility_mi>10.0</visibility_mi>
    <visibility_km>16.1</visibility_km>
    <solarradiation>204</solarradiation>
    <UV>0.0</UV>
    <precip_1hr_string>0.00 in ( 0 mm)</precip_1hr_string>
    <precip_1hr_in>0.00</precip_1hr_in>
    <precip_1hr_metric>0</precip_1hr_metric>
    <precip_today_string>0.00 in (0 mm)</precip_today_string>
    <precip_today_in>0.00</precip_today_in>
    <precip_today_metric>0</precip_today_metric>
    <icon>mostlycloudy</icon>
    <icon_url>http://icons-ak.wxug.com/i/c/k/mostlycloudy.gif</icon_url>
    <forecast_url>http://www.wunderground.com/US/CA/Santa_Maria.html</forecast_url>
    <history_url>
    http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KCAORCUT2
    </history_url>
    <ob_url>
    http://www.wunderground.com/cgi-bin/findweather/getForecast?query=34.883854,-120.422493
    </ob_url>
    </current_observation>
    </response>

     

    So, here's what I did to make mine work. Go to File>Presentation Properties>Data Feeds

    1.  Put the url of the xml into "Feed Specifications"

    2. Choose your update interval

    3. In "plugin script" point it to the .brs file that I will explain next in My case "parser_wunderground.brs"

    4. In "Parser Function Name" put the function name you specify in the script "ParseSlocum" in my case

     

    OK, so the contents of the "parser_wunderground.brs" file is this.

    Sub ParseSlocum(xmlFileName$ as String, itemsByIndex as object, itemsByTitle as Object, userVariables As Object)
    xml = CreateObject("roXMLElement")

    if not xml.Parse(ReadAsciiFile(xmlFileName$)) then
    print "xml read failed"
    else

    itemsbyindex[0] = str(int(val(xml.current_observation.temp_f.gettext()))) 'Current temperature rounded to a whole number

    for each itemxml in xml.forecast.simpleforecast.forecastdays.forecastday
    print itemxml
    index%=0
    if index% = 2 exit for

    if index%=0 then
    itemsbyindex.push(UCase(itemxml.date.weekday.gettext())) 'UPPERCASE weekday name
    itemsbyindex.push("H "+itemxml.high.fahrenheit.gettext()+"F") 'Forecasted high temp for the day above with F added after the number
    itemsbyindex.push("L "+itemxml.low.fahrenheit.gettext()+"F") 'Forecasted low temp for the day above with F added after the number
    itemsbyindex.push(itemxml.date.weekday.gettext()+": H "+itemxml.high.fahrenheit.gettext()+"F "+"L "+itemxml.low.fahrenheit.gettext()+"F") 'name of day and high and low
    itemsbyindex.push("H:"+itemxml.high.fahrenheit.gettext()+"F | L:"+itemxml.low.fahrenheit.gettext()+"F") 'The letter H, then a : then the forecasted high, then "F | L:" then the low, then another F
    itemsbyindex.push(itemxml.conditions.gettext()) 'short summary of forecasted conditions

    endif

    if index%=1 then
    itemsbyindex.push(UCase(itemxml.date.weekday.gettext())) 'UPPERCASE weekday name
    itemsbyindex.push("H "+itemxml.high.fahrenheit.gettext()+"F") 'Forecasted high temp for the day above with F added after the number
    itemsbyindex.push("L "+itemxml.low.fahrenheit.gettext()+"F") 'Forecasted low temp for the day above with F added after the number
    itemsbyindex.push(itemxml.date.weekday.gettext()+": H "+itemxml.high.fahrenheit.gettext()+"F "+"L "+itemxml.low.fahrenheit.gettext()+"F") 'name of day and high and low
    itemsbyindex.push("H:"+itemxml.high.fahrenheit.gettext()+"F | L:"+itemxml.low.fahrenheit.gettext()+"F") 'The letter H, then a : then the forecasted high, then "F | L:" then the low, then another F
    itemsbyindex.push(itemxml.conditions.gettext()) 'short summary of forecasted conditions

    endif

    next

    endif

    End Sub

     

    And then I just use the Index numbers to display the info I want.  I found it helpful to just publish a presentation with index numbers 1-20 or so and then use that as a reference to see which index number is the one I really wanted.  Hope all the helps someone!  Special thanks to Brightsign support for helping me understand all this!!

     

    Ben Slocum

  • 0
    Avatar
    Shaun

     Thanks for the full script, with comments!. Definitely a good starting point. I have already put together a a sample Mrss xml would be using that to swap background image and using a modified version of you parser script to pull out the other needed <tags> and display them as live text over the top.

    Thanks, 

Please sign in to leave a comment.