-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse.go
48 lines (43 loc) · 1.13 KB
/
parse.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
package hoidy
import (
"encoding/xml"
"io/ioutil"
"os"
)
// Corporation company info
// https://www.houjin-bangou.nta.go.jp/download/
type Corporation struct {
SequenceNumber string `xml:"sequenceNumber"`
CorporateNumber string `xml:"corporateNumber"`
Process string `xml:"process"`
// UpdateDate time.Time `xml:"updateDate"`
UpdateDate string `xml:"updateDate"`
// ChangeDate time.Time `xml:"changeDate"`
ChangeDate string `xml:"changeDate"`
Name string `xml:"name"`
PrefectureName string `xml:"prefectureName"`
CityName string `xml:"cityName"`
StreetNumber string `xml:"streetNumber"`
Furigana string `xml:"furigana"`
}
type Corporations struct {
XMLName xml.Name `xml:"corporations"`
Corporations []Corporation `xml:"corporation"`
}
// ParseXML houjin ID XML parser
func ParseXML(pt string) (*Corporations, error) {
f, err := os.Open(pt)
if err != nil {
return nil, err
}
defer f.Close()
c, err := ioutil.ReadAll(f)
if err != nil {
return nil, err
}
var cms Corporations
if err := xml.Unmarshal(c, &cms); err != nil {
return nil, err
}
return &cms, nil
}