I'd like to marshal a struct into XML, but without encoding special HTML-entities. See this example:
http://play.golang.org/p/7NOhOTwlHr
The string test&abc gets converted to test&abc, but I'd like it to stay test&abc
You can use the tag ",innerxml" as show in the example. Here it explains that ",innerxml" makes unmarshal "assign raw XML data to it". But it also work well with Marshal avoiding the string formating.
http://play.golang.org/p/z8JQjRdbV4
The ampersand is escaped using the rules in the XML specification. It is not possible to disable escaping in the output of the standard encoding/xml package.
(Ampersand escaping in HTML and XML shares a common heritage from SGML, but each is specified separately. One does not derive from or reference the other).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With