Golang encoding/xml.EscapeText() function example
package encoding/xml
EscapeText writes to w(1st parameter) the properly escaped XML equivalent of the plain text data s (2nd parameter).
Golang encoding/xml.EscapeText() function usage example
package main
import (
"encoding/xml"
"os"
"fmt"
)
func main() {
str := "\"'&<>"
err := xml.EscapeText(os.Stdout, []byte(str))
if err != nil {
fmt.Println(err)
}
}
Output :
"'&<>
Reference :
Advertisement
Something interesting
Tutorials
+9.6k Golang : Validate IPv6 example
+6.3k Golang : Selection sort example
+23.5k Golang : Get ASCII code from a key press(cross-platform) example
+13.1k Golang : How to get a user home directory path?
+19.1k Golang : Display list of time zones with GMT
+12.4k Golang : Search and extract certain XML data example
+5.3k Golang : Generate Interleaved 2 inch by 5 inch barcode
+6.2k Linux/Unix : Commands that you need to be careful about
+18.6k Golang : Iterating Elements Over A List
+11.6k Golang : Display a text file line by line with line number example
+37.5k Golang : Converting a negative number to positive number
+16.8k Golang : Get own process identifier