Re: [go-nuts] Re: Unmarshal nested XML value from dynamic XML document

2019-02-24 Thread Steffen Wentzel
Very nice, `xml:",any"` was doing the trick. I've condensed the function and here's the (currently) final result: https://play.golang.org/p/G1eGw5gtk7C func id3(axl []byte) string { type Return struct { Response struct { Return string `xml:"return"` } `xml:",any"` } var ret Return err :=

Re: [go-nuts] Re: Unmarshal nested XML value from dynamic XML document

2019-02-24 Thread Matt Harden
You don't have to use an xml.Decoder. You may be able to use the `xml:",any"` tag for this case. type Response struct { XMLName xml.Name Return string `xml:"return"` } type Outer struct { XMLName struct{} `xml:"outer"` Responses []Response `xml:",any"` }

Re: [go-nuts] Re: Unmarshal nested XML value from dynamic XML document

2019-02-24 Thread Sam Whited
Your function appears to return error text, but it will be much more clear what's going on when reading the code if you encode your intent in the return type and return an error instead of a string (which gives me no information about what that string is supposed to represent: is it an error?

[go-nuts] Re: Unmarshal nested XML value from dynamic XML document

2019-02-24 Thread Steffen Wentzel
Thanks for the response. I was hoping it would be possible with just xml.Unmarshal. I now have this implementation - any comments on that? (I'm okay with returning the error inline, it's just for logging purposes): Playground: https://play.golang.org/p/6J8XndWdlv_N func id2(axl []byte) string