Re: [go-nuts] Unmarshal mixed XML content

2017-01-06 Thread John Leidegren
Yeah, I was using regexp at one point. It's less code but it just isn't right to parse XML with it. Not when the xml.Decoder exposes such a nice API. On Friday, January 6, 2017 at 12:55:37 PM UTC+1, Egon wrote: > > > > On Friday, 6 January 2017 13:28:22 UTC+2, John Leidegren wrote: >> >> So afte

Re: [go-nuts] Unmarshal mixed XML content

2017-01-06 Thread Egon
On Friday, 6 January 2017 13:28:22 UTC+2, John Leidegren wrote: > > So after talking a look at the xml package again I noticed the > UnmarshalXML trap. So I used that. Here's the solution I went with. > > I wrapped the decoder in a recursive decent parser to make the actual > UnmarshalXML metho

Re: [go-nuts] Unmarshal mixed XML content

2017-01-06 Thread John Leidegren
So after talking a look at the xml package again I noticed the UnmarshalXML trap. So I used that. Here's the solution I went with. I wrapped the decoder in a recursive decent parser to make the actual UnmarshalXML method readable. https://play.golang.org/p/dylYB0KsyL It uses an example from th

Re: [go-nuts] Unmarshal mixed XML content

2017-01-06 Thread Egon
You can use xml.Decoder (https://play.golang.org/p/fkp-t4_vee). Can you show in which place OpenGL registry contains such entries? Just interested in why it is encoded that way. Also take a look at https://github.com/go-gl/glow + Egon On Friday, 6 January 2017 11:28:42 UTC+2, John Leidegren wr

Re: [go-nuts] Unmarshal mixed XML content

2017-01-06 Thread John Leidegren
OK, then I give up. If that is how it works. The source XML file I'm reading is from the OpenGL registry and I cannot change the way they structured that file. What baffles me is that I can't seem to simply concat the text nodes either. I'd like to, as an option, just read the the concatenated

Re: [go-nuts] Unmarshal mixed XML content

2017-01-05 Thread Shawn Milochik
On Thu, Jan 5, 2017 at 2:40 PM, John Leidegren wrote: > See https://play.golang.org/p/XjKdm7Pooh > > I was hoping to get back a, b followed by c but I get a, c then b. I just > can't get this to work. > > How is it even possible for it to read character data from before and > after the B node? >

[go-nuts] Unmarshal mixed XML content

2017-01-05 Thread John Leidegren
See https://play.golang.org/p/XjKdm7Pooh I was hoping to get back a, b followed by c but I get a, c then b. I just can't get this to work. How is it even possible for it to read character data from before and after the B node? -- You received this message because you are subscribed to the Goo