| 1 |
// Copyright 2011 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package xml |
| 6 |
|
| 7 |
import "time" |
| 8 |
|
| 9 |
var atomValue = &Feed{ |
| 10 |
XMLName: Name{"http://www.w3.org/2005/Atom", "feed"}, |
| 11 |
Title: "Example Feed", |
| 12 |
Link: []Link{{Href: "http://example.org/"}}, |
| 13 |
Updated: ParseTime("2003-12-13T18:30:02Z"), |
| 14 |
Author: Person{Name: "John Doe"}, |
| 15 |
ID: "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6", |
| 16 |
|
| 17 |
Entry: []Entry{ |
| 18 |
{ |
| 19 |
Title: "Atom-Powered Robots Run Amok", |
| 20 |
Link: []Link{{Href: "http://example.org/2003/12/13/atom03"}}, |
| 21 |
ID: "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a", |
| 22 |
Updated: ParseTime("2003-12-13T18:30:02Z"), |
| 23 |
Summary: NewText("Some text."), |
| 24 |
}, |
| 25 |
}, |
| 26 |
} |
| 27 |
|
| 28 |
var atomXML = `` + |
| 29 |
`<feed xmlns="http://www.w3.org/2005/Atom" updated="2003-12-13T18:30:02Z">` + |
| 30 |
`<title>Example Feed</title>` + |
| 31 |
`<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>` + |
| 32 |
`<link href="http://example.org/"></link>` + |
| 33 |
`<author><name>John Doe</name><uri></uri><email></email></author>` + |
| 34 |
`<entry>` + |
| 35 |
`<title>Atom-Powered Robots Run Amok</title>` + |
| 36 |
`<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>` + |
| 37 |
`<link href="http://example.org/2003/12/13/atom03"></link>` + |
| 38 |
`<updated>2003-12-13T18:30:02Z</updated>` + |
| 39 |
`<author><name></name><uri></uri><email></email></author>` + |
| 40 |
`<summary>Some text.</summary>` + |
| 41 |
`</entry>` + |
| 42 |
`</feed>` |
| 43 |
|
| 44 |
func ParseTime(str string) time.Time { |
| 45 |
t, err := time.Parse(time.RFC3339, str) |
| 46 |
if err != nil { |
| 47 |
panic(err) |
| 48 |
} |
| 49 |
return t |
| 50 |
} |
| 51 |
|
| 52 |
func NewText(text string) Text { |
| 53 |
return Text{ |
| 54 |
Body: text, |
| 55 |
} |
| 56 |
} |