Golang encoding/xml.Escape() function example

package encoding/xml

Escape is like EscapeText but omits the error return value. It is provided for backwards compatibility with Go 1.0. Code targeting Go 1.1 or later should use EscapeText.

Golang encoding/xml.Escape() function usage example

 package main

 import (
 "encoding/xml"
 "os"
 )

 func main() {
 str := "\"'&<>"
 xml.Escape(os.Stdout, []byte(str))
 }

Output :

&#34; &#39;&amp;&lt;&gt;

Reference :

http://golang.org/pkg/encoding/xml/#Escape

Advertisement