1
0
mirror of https://github.com/aclindsa/ofxgo.git synced 2025-07-01 11:48:38 -04:00

Reorganization

This commit is contained in:
2017-03-17 21:35:26 -04:00
parent add6036729
commit 8158868432
6 changed files with 173 additions and 150 deletions

25
util.go Normal file
View File

@ -0,0 +1,25 @@
package ofxgo
import (
"bytes"
"github.com/golang/go/src/encoding/xml"
)
// Returns the next available Token from the xml.Decoder that is not CharData
// made up entirely of whitespace. This is useful to skip whitespace when
// manually unmarshaling XML.
func nextNonWhitespaceToken(decoder *xml.Decoder) (xml.Token, error) {
for {
tok, err := decoder.Token()
if err != nil {
return nil, err
} else if chars, ok := tok.(xml.CharData); ok {
strippedBytes := bytes.TrimSpace(chars)
if len(strippedBytes) != 0 {
return tok, nil
}
} else {
return tok, nil
}
}
}