XML utils
This don't stable version
Implementation features
Forwarding xmlutils.Decoder via the xml.UnmarshalXML interface
package main
import (
"fmt"
"encoding/xml"
"github.com/mantyr/xmlutils"
)
type A struct {
B struct {
Data string `xml:"prefix:data"`
}
}
func (a *A) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
return xmlutils.NewTokenDecoder(d, start).Decode(&a.B)
}
func main() {
data := `<a><prefix:data>test</prefix:data></a>`
a := &A{}
err := xml.Unmarshal([]byte(data), &a)
fmt.Println(err)
fmt.Println(a.B.Data)
}
Installation
$ go get -u github.com/mantyr/xmlutils
Author
Oleg Shevelev