Standard library / encoding/xml
encoding/xml.EscapeText()
Writes escaped XML character data, propagating write errors. Expected stdout: 'a&b\n'.
Formal Syntax & Structure
go syntaxgo
func EscapeText(w io.Writer, s []byte) errorParameters & Attributes
| Name | Type | Description |
|---|---|---|
| w | io.Writer | Output stream. |
| s | []byte | Input text or bytes. |
Return Value
error
Nil on success; otherwise the operation error.
Working Example
Example Snippetgo
package main
import ( "bytes" "encoding/xml" "fmt")
func must(e error) { if e != nil { panic(e) }}
func main() { var out bytes.Buffer must(xml.EscapeText(&out, []byte("a&b"))) fmt.Println(out.String())}