go - Golang: UnmarshalXMLAttr in encoding/xml -


I'm trying to disassociate some XMR, where I want to parse the attributes in a particular way. I have tried to use it, but I can not work it. Using the following code, I only get one output '{castle}'

package main import ("encoding / XML" "FMT" String ") Show type string {title string} xml:" title, entry "`} function (S * Show) UnmarshalXMLAttr (attr xml.Attr) error {fmt.Printf ("attribute '% s' parsing value'% s '', Attr.Name.Local, attr.Value) s.Title = Wired ToUpper (attr.Value) return zero} func main () {b: = [] byte (`

Any thoughts?

attribute unmarshaler should be a type of title , Not the show. Here is a definite version:

First of all, we create a "wrong type" that wraps the string and applies the interface

  type Title string  

We now define the title field as our type

This will call our attribute for this attribute

  Show Type Structure {Title Title: `Xml:" Title, Atr " `}  

and now our custom unmounted for:

  Funk (S * title) UnmarshalXMLAttr (attr) Xml.Attr) error {fmt. Printf ("property '% s' parsing value '% s'", attr.Name.Local, attr.Value) * s = title (strings.toUpper (attr.Value)) returns blue}  

The rest remains the same:

  func main () {b: = [] byte (` 

>

/ html>

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -