trying to learn xml unmarshaling

35 views
Skip to first unread message

rob

unread,
Jun 7, 2017, 8:03:57 AM6/7/17
to golan...@googlegroups.com
Hi. I am trying to unmarshal the xml file I get from my bank. It seems
that the unmarshal routine cannot deal w/ the nested html fields.

sample.qfx

OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE

<OFX>
<SIGNONMSGSRSV1>
<SONRS>
<STATUS>
<CODE>0
<SEVERITY>INFO
</STATUS>
<DTSERVER>20170602063954
<LANGUAGE>ENG
<FI>
<ORG>Citibank
<FID>2102
</FI>
<INTU.BID>2102
</SONRS>
</SIGNONMSGSRSV1>

type citixmlheadertype struct {
DTSERVER string `xml:"DTSERVER,OFX>SIGNONMSGSRSV1>SONRS" `
LANGUAGE string `xml:"LANGUAGE,OFX>SIGNONMSGSRSV1>SONRS" `
ORG string `xml:"ORG,OFX>SIGNONMSGSRSVR1>SONRS>FI" `
FID int `xml:"FID,OFX>SIGNONMSGSRSVR1>SONRS>FI" `
CURDEF string `xml:"CURDEF,OFX>BANKMSGSRSV1>STMTTRNRS"`
BANKID string `xml:"BANKID,OFX>BANKMSGSRSV1>STMTTRNRS>BANKACCTFROM"`
ACCTID string `xml:"ACCTID,OFX>BANKMSGSRSV1>STMTTRNRS>BANKACCTFROM"`
ACCTTYPE string
`xml:"ACCTTYPE,OFX>BANKMSGSRSV1>STMTTRNRS>BANKACCTFROM"`
DTSTART string `xml:"DTSTART,OFX>BANKMSGSRSV1>STMTTRNRS>BANKTRANLIST"`
DTEND string `xml:"DTEND,OFX>BANKMSGSRSV1>STMTTRNRS>BANKTRANLIST"`
}

var citiheader citixmlheadertype
e = xml.Unmarshal(filebyteslice, &citiheader) // this requires a []byte
if e != nil {
fmt.Println(" Unmarshalling the header error", e)
os.Exit(1)
}
fmt.Printf(" header %#v \n", citiheader)

I'm getting an xml syntax error that "element <SEVERITY> closed by </STATUS>

I guess I don't understand this yet.

Thanks,

Rob Solomon

Tamás Gulácsi

unread,
Jun 7, 2017, 8:15:02 AM6/7/17
to golang-nuts
Where is SEVERITY tag closed? The text you copied here is not an XML.

Val

unread,
Jun 7, 2017, 8:42:44 AM6/7/17
to golang-nuts
This looks like OFX  (Open Financial Exchange) which indeed is probably not XML.
Reply all
Reply to author
Forward
0 new messages