From the course: Learning the Go Standard Library

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Encoding XML

Encoding XML - Go Tutorial

From the course: Learning the Go Standard Library

Start my 1-month free trial

Encoding XML

- [Instructor] Previously in the chapter, we saw how to encode data contained within Go structs in to JSON. And in this example we're going to do the same thing with XML. So XML is a bit more complex than JSON. But the process that you use to encode it in Go is pretty much the same as it is for JSON. So, let's open the code for the encoding example in our editor. And similar to the JSON example we'll see how to decode it in a separate video. So here in chapter five in the Start folder, let's open XMLEncode. And you can see that I have a struct here that represents some data about a person. And so let's scroll down a little bit. And we'll uncomment this code that creates a couple of person records. And one of them will have favorite colors and one will not. Oh, let's also uncomment the code that imports the packages I'm going to use. All right. So now I'm using encoding XML instead of encoding JSON. So, to…

Contents