-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
82 lines (76 loc) · 1.56 KB
/
model.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package main
import "encoding/xml"
type Collection struct {
XMLName xml.Name `xml:"collection"`
Text string `xml:",chardata"`
Xsi string `xml:"xsi,attr"`
SchemaLocation string `xml:"schemaLocation,attr"`
Rec []Rec `xml:"rec"`
}
type Rec struct {
Text string `xml:",chardata"`
Lab string `xml:"lab"`
Cf []struct {
Text string `xml:",chardata"`
T string `xml:"t,attr"`
} `xml:"cf"`
Df []struct {
Text string `xml:",chardata"`
T string `xml:"t,attr"`
I1 string `xml:"i1,attr"`
I2 string `xml:"i2,attr"`
Sf []struct {
Text string `xml:",chardata"`
C string `xml:"c,attr"`
} `xml:"sf"`
S1 []struct {
Text string `xml:",chardata"`
Cf struct {
Text string `xml:",chardata"`
T string `xml:"t,attr"`
} `xml:"cf"`
Df struct {
Text string `xml:",chardata"`
T string `xml:"t,attr"`
I1 string `xml:"i1,attr"`
I2 string `xml:"i2,attr"`
Sf []struct {
Text string `xml:",chardata"`
C string `xml:"c,attr"`
} `xml:"sf"`
} `xml:"df"`
} `xml:"s1"`
} `xml:"df"`
}
func (r *Rec) ID() string {
for _, cf := range r.Cf {
if cf.T == "001" {
return cf.Text
}
}
return ""
}
func (r *Rec) ISBN() string {
for _, df := range r.Df {
if df.T == "010" {
for _, sf := range df.Sf {
if sf.C == "a" {
return sf.Text
}
}
}
}
return ""
}
func (r *Rec) Title() string {
for _, df := range r.Df {
if df.T == "200" {
for _, sf := range df.Sf {
if sf.C == "a" {
return sf.Text
}
}
}
}
return ""
}