Golang encoding/xml.Comment type example

package encoding/xml

A Comment represents an XML comment of the form . The bytes do not include the comment markers.

Golang encoding/xml.Comment type example

 ...
 switch t := t.(type) {
  case CharData:
 EscapeText(p, t)
  case Comment:  // <--- here
 if bytes.Contains(t, endComment) {
 return fmt.Errorf("xml: EncodeToken of Comment containing --> marker")
 }
 p.WriteString("<!--")
 p.Write(t)
 p.WriteString("-->")
 ...

Reference :

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

Advertisement