Instantly share code, notes, and snippets.

Embed
What would you like to do?
Blog examples
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-ca">
<!--
This is a data file that is meant to be read by RSS readers or aggregators.
See http://www.ec.gc.ca/meteo-weather/default.asp?lang=En&n=11703207-1 to learn more about our RSS service.
-->
<title>Winnipeg - Weather - Environment Canada</title>
<link rel="related" href="http://www.weather.gc.ca/city/pages/mb-38_metric_e.html" type="text/html"/>
<link rel="self" href="http://www.weather.gc.ca/rss/city/mb-38_e.xml" type="application/atom+xml"/>
<link rel="alternate" hreflang="fr-ca" href="http://www.meteo.gc.ca/rss/city/mb-38_f.xml" type="application/atom+xml"/>
<author>
<name>Environment Canada</name>
<uri>http://www.weather.gc.ca</uri>
</author>
<updated>2015-02-20T02:05:27Z</updated>
<id>tag:weather.gc.ca,2013-04-16:20150220020527</id>
<logo>http://www.weather.gc.ca/build/theme-gcwu-fegc/images/wmms.gif</logo>
<icon>http://www.weather.gc.ca/build/theme-gcwu-fegc/images/favicon.ico</icon>
<rights>Copyright 2015, Environment Canada</rights>
<entry>
<title>No watches or warnings in effect, Winnipeg</title>
<link type="text/html" href="http://www.weather.gc.ca/warnings/index_e.html"/>
<updated>2015-02-19T17:15:00Z</updated>
<published>2015-02-19T17:15:00Z</published>
<category term="Warnings and Watches"/>
<summary type="html">No watches or warnings in effect.</summary>
<id>tag:weather.gc.ca,2013-04-16:mb-38_w1:20150219171500</id>
</entry>
<entry>
<title>Current Conditions: Drifting Snow, -15.2&#xB0;C</title>
<link type="text/html" href="http://www.weather.gc.ca/city/pages/mb-38_metric_e.html"/>
<updated>2015-02-20T02:00:00Z</updated>
<published>2015-02-20T02:00:00Z</published>
<category term="Current Conditions"/>
<summary type="html"><![CDATA[<b>Observed at:</b> Winnipeg Richardson Int'l Airport 8:00 PM CST Thursday 19 February 2015 <br/>
<b>Condition:</b> Drifting Snow <br/>
<b>Temperature:</b> -15.2&deg;C <br/>
<b>Pressure / Tendency:</b> 101.7 kPa falling<br/>
<b>Visibility:</b> 24.1 km<br/>
<b>Humidity:</b> 72 %<br/>
<b>Wind Chill:</b> -28 <br/>
<b>Dewpoint:</b> -19.2&deg;C <br/>
<b>Wind:</b> S 45 km/h gust 55 km/h<br/>
<b>Air Quality Health Index:</b> 3 <br/>
]]></summary>
<id>tag:weather.gc.ca,2013-04-16:mb-38_cc:20150220020000</id>
</entry>
<entry>
<title>Thursday night: Periods of light snow. Temperature rising to minus 13 by morning.</title>
<link type="text/html" href="http://www.weather.gc.ca/city/pages/mb-38_metric_e.html"/>
<updated>2015-02-19T22:00:00Z</updated>
<published>2015-02-19T22:00:00Z</published>
<category term="Weather Forecasts"/>
<summary type="html">Partly cloudy. Becoming cloudy this evening then periods of light snow. Wind south 30 km/h gusting to 50 becoming light overnight. Temperature rising to minus 13 by morning. Wind chill minus 29. Forecast issued 4:00 PM CST Thursday 19 February 2015</summary>
<id>tag:weather.gc.ca,2013-04-16:mb-38_fc1:20150219220000</id>
</entry>
<entry>
<title>Friday: Chance of flurries. Temperature steady near minus 13. POP 30%</title>
<link type="text/html" href="http://www.weather.gc.ca/city/pages/mb-38_metric_e.html"/>
<updated>2015-02-19T22:00:00Z</updated>
<published>2015-02-19T22:00:00Z</published>
<category term="Weather Forecasts"/>
<summary type="html">Periods of light snow ending in the morning then cloudy with 30 percent chance of flurries. Wind becoming north 20 km/h in the morning. Temperature steady near minus 13. Forecast issued 4:00 PM CST Thursday 19 February 2015</summary>
<id>tag:weather.gc.ca,2013-04-16:mb-38_fc2:20150219220000</id>
</entry>
<entry>
<title>Friday night: Clearing. Low minus 28.</title>
<link type="text/html" href="http://www.weather.gc.ca/city/pages/mb-38_metric_e.html"/>
<updated>2015-02-19T22:00:00Z</updated>
<published>2015-02-19T22:00:00Z</published>
<category term="Weather Forecasts"/>
<summary type="html">Clearing in the evening. Wind north 20 km/h. Low minus 28. Extreme wind chill minus 41. Forecast issued 4:00 PM CST Thursday 19 February 2015</summary>
<id>tag:weather.gc.ca,2013-04-16:mb-38_fc3:20150219220000</id>
</entry>
<entry>
<title>Saturday: Sunny. High minus 23.</title>
<link type="text/html" href="http://www.weather.gc.ca/city/pages/mb-38_metric_e.html"/>
<updated>2015-02-19T22:00:00Z</updated>
<published>2015-02-19T22:00:00Z</published>
<category term="Weather Forecasts"/>
<summary type="html">Sunny. High minus 23. Forecast issued 4:00 PM CST Thursday 19 February 2015</summary>
<id>tag:weather.gc.ca,2013-04-16:mb-38_fc4:20150219220000</id>
</entry>
<entry>
<title>Sunday: Sunny. Low minus 32. High minus 25.</title>
<link type="text/html" href="http://www.weather.gc.ca/city/pages/mb-38_metric_e.html"/>
<updated>2015-02-19T22:00:00Z</updated>
<published>2015-02-19T22:00:00Z</published>
<category term="Weather Forecasts"/>
<summary type="html">Sunny. Low minus 32. High minus 25. Forecast issued 4:00 PM CST Thursday 19 February 2015</summary>
<id>tag:weather.gc.ca,2013-04-16:mb-38_fc5:20150219220000</id>
</entry>
<entry>
<title>Monday: Chance of flurries. Low minus 25. High minus 12. POP 30%</title>
<link type="text/html" href="http://www.weather.gc.ca/city/pages/mb-38_metric_e.html"/>
<updated>2015-02-19T22:00:00Z</updated>
<published>2015-02-19T22:00:00Z</published>
<category term="Weather Forecasts"/>
<summary type="html">A mix of sun and cloud with 30 percent chance of flurries. Low minus 25. High minus 12. Forecast issued 4:00 PM CST Thursday 19 February 2015</summary>
<id>tag:weather.gc.ca,2013-04-16:mb-38_fc6:20150219220000</id>
</entry>
<entry>
<title>Tuesday: Sunny. Low minus 23. High minus 18.</title>
<link type="text/html" href="http://www.weather.gc.ca/city/pages/mb-38_metric_e.html"/>
<updated>2015-02-19T22:00:00Z</updated>
<published>2015-02-19T22:00:00Z</published>
<category term="Weather Forecasts"/>
<summary type="html">Sunny. Low minus 23. High minus 18. Forecast issued 4:00 PM CST Thursday 19 February 2015</summary>
<id>tag:weather.gc.ca,2013-04-16:mb-38_fc7:20150219220000</id>
</entry>
<entry>
<title>Wednesday: Sunny. Low minus 25. High minus 15.</title>
<link type="text/html" href="http://www.weather.gc.ca/city/pages/mb-38_metric_e.html"/>
<updated>2015-02-19T22:00:00Z</updated>
<published>2015-02-19T22:00:00Z</published>
<category term="Weather Forecasts"/>
<summary type="html">Sunny. Low minus 25. High minus 15. Forecast issued 4:00 PM CST Thursday 19 February 2015</summary>
<id>tag:weather.gc.ca,2013-04-16:mb-38_fc8:20150219220000</id>
</entry>
</feed>
package main
import (
"encoding/xml"
"fmt"
"io/ioutil"
)
type Entry struct {
Title string `xml:"title"`
Link string `xml:"link"`
Updated string `xml:"updated"`
Published string `xml:"published"`
Category string `xml:"category"`
Summary string `xml:"summary"`
}
type Feed struct {
XMLName xml.Name `xml:"feed"`
Title string `xml:"title"`
Subtitle string `xml:"subtitle"`
Id string `xml:"id"`
Updated string `xml:"updated"`
Logo string `xml:"logo"`
Icon string `xml:"icon"`
Rights string `xml:"rights"`
Entries []Entry `xml:"entry"`
}
func main() {
dat, err := ioutil.ReadFile("mb-38_e.xml")
if err != nil {
panic(err)
}
var f Feed
err2 := xml.Unmarshal(dat, &f)
if err2 != nil {
panic(err2)
}
fmt.Printf("Title: %q\n", f.Title)
fmt.Printf("Subtitle: %q\n", f.Subtitle)
fmt.Printf("Id: %q\n", f.Id)
fmt.Printf("Updated: %q\n", f.Updated)
fmt.Printf("Logo: %q\n", f.Logo)
fmt.Printf("Icon: %q\n", f.Icon)
fmt.Printf("Rights: %q\n", f.Rights)
fmt.Printf("Entries: %v\n", f.Entries)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment