/
unmarshal.go
62 lines (53 loc) · 1.51 KB
/
unmarshal.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package sic
import (
"encoding/xml"
"github.com/pkg/errors"
)
type Database struct {
Notes []string `xml:"notes"`
LabelID []string `xml:"label_id"`
File [][]File `xml:"file"`
Ghost []Ghost `xml:"ghost"`
Label []Label `xml:"label"`
Card []Card `xml:"card"`
}
type Ghost struct {
ID string `xml:"id,attr"`
TimeStamp string `xml:"time_stamp,attr"`
}
type Label struct {
Type string `xml:"type,attr"`
TimeStamp string `xml:"time_stamp,attr"`
ID string `xml:"id,attr"`
Name string `xml:"name,attr"`
}
type Card struct {
ID string `xml:"id,attr"`
Symbol string `xml:"symbol,attr"`
Template string `xml:"template,attr"`
Type string `xml:"type,attr"`
WebsiteIcon string `xml:"website_icon,attr"`
TimeStamp string `xml:"time_stamp,attr"`
Deleted string `xml:"deleted,attr"`
Title string `xml:"title,attr"`
Color string `xml:"color,attr"`
Star string `xml:"star,attr"`
Field []Field `xml:"field"`
}
type Field struct {
Hash string `xml:"hash,attr"`
History string `xml:"history,attr"`
Name string `xml:"name,attr"`
Type string `xml:"type,attr"`
Text string `xml:",chardata"`
Score string `xml:"score,attr"`
}
type File struct {
Name string `xml:"name,attr"`
Text string `xml:",chardata"`
}
// Unmarshal converts the xml in []byte into a Go struct
func Unmarshal(raw []byte) (*Database, error) {
var db *Database
return db, errors.Wrap(xml.Unmarshal(raw, &db), "could not Unmarshal xml")
}