package svg import "encoding/xml" import "strings" type Style map[string]string func ParseStyle(str string) (Style, error) { res := make(Style) rules := strings.Split(";", str) for _, rule := range rules { parts := strings.SplitN(rule, ":", 2) key := parts[0] value := "true" if len(parts) > 1 { value = parts[1] } res[key] = value } return res, nil } func (s *Style) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { var value string // Read tag content into value d.DecodeElement(&value, &start) style, err := ParseStyle(value) if err != nil { return err } *s = style return nil }