-
Notifications
You must be signed in to change notification settings - Fork 2
/
xml_format.go
81 lines (72 loc) · 2.26 KB
/
xml_format.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
package disqusimportorgo
import "encoding/xml"
// Disqus: Disqus comment export structure in go
type DisqusStruct struct {
XMLName xml.Name `xml:"disqus"`
Text string `xml:",chardata"`
Xmlns string `xml:"xmlns,attr"`
Dsq string `xml:"dsq,attr"`
Xsi string `xml:"xsi,attr"`
SchemaLocation string `xml:"schemaLocation,attr"`
Category CategoryStruct `xml:"category"`
Articles []Article `xml:"thread"`
Commments []Comment `xml:"post"`
}
type CategoryStruct struct {
Text string `xml:",chardata"`
ID string `xml:"id,attr"`
Forum string `xml:"forum"`
Title string `xml:"title"`
IsDefault string `xml:"isDefault"`
}
type Comment struct {
Text string `xml:",chardata"`
AttrID string `xml:"id,attr"`
ID string `xml:"id"`
Message string `xml:"message"`
CreatedAt string `xml:"createdAt"`
IsDeleted string `xml:"isDeleted"`
IsSpam string `xml:"isSpam"`
Author AuthorStruct `xml:"author"`
ArticleLink ArticleLinkStruct `xml:"thread"`
Parent struct {
Text string `xml:",chardata"`
ID string `xml:"id,attr"`
} `xml:"parent"`
}
type ArticleLinkStruct struct {
Text string `xml:",chardata"`
ID string `xml:"id,attr"`
}
type Article struct {
Text string `xml:",chardata"`
AttrID string `xml:"id,attr"`
ID string `xml:"id"`
Forum string `xml:"forum"`
Category struct {
Text string `xml:",chardata"`
ID string `xml:"id,attr"`
} `xml:"category"`
Link string `xml:"link"`
Title string `xml:"title"`
Message string `xml:"message"`
CreatedAt string `xml:"createdAt"`
Author AuthorStruct `xml:"author"`
IsClosed string `xml:"isClosed"`
IsDeleted string `xml:"isDeleted"`
}
type AuthorStruct struct {
Text string `xml:",chardata"`
Name string `xml:"name"`
IsAnonymous string `xml:"isAnonymous"`
Username string `xml:"username"`
}
func (a Article) GetAuthorName() string {
return a.Author.Name
}
func (a Article) GetArticleLink() string {
return a.Link
}
func (c Comment) GetAuthorName() string {
return c.Author.Name
}