Quick actions

cmd+k|ctrl+k

Navigation

Languages

XML / Configuring XML parsing and serialization / Essential Go

Snippet info

Language

Go

Visibility

public

Author

kkowalczyk

Created

2019-03-26T09:43:32Z

Updated

2019-03-26T09:43:32Z

package main

import (
	"encoding/xml"
	"fmt"
	"log"
)

type ShowInnerXML struct {
	Str string `xml:"s"`
	Raw string `xml:",innerxml"`
}

func printXML(v interface{}) {
	d, err := xml.Marshal(v)
	if err != nil {
		log.Fatalf("xml.Marshal failed with '%s'\n", err)
	}
	fmt.Printf("XML: %s\n\n", string(d))
}

func main() {
	v := &ShowInnerXML{
		Str: "<foo></foo>",
		Raw: "<foo></foo>",
	}
	printXML(v)

}
INFO