Jump to content

XML/Output: Difference between revisions

→‎{{header|Go}}: update for new template library, also added an error check
No edit summary
(→‎{{header|Go}}: update for new template library, also added an error check)
Line 617:
 
import (
"iobytes"
"fmt"
"os"
"template"
Line 633 ⟶ 634:
 
var tmpl = `<CharacterRemarks>
{{range .}} <Character name="{{xml .Char}}">{{xml .Rem}}</Character>
{.repeated section @}
{{end}}</CharacterRemarks>
<Character name="{Char}">{Rem}</Character>
{.end}
</CharacterRemarks>
`
 
func xmlFormatterxmlEscapeString(ws io.Writer, _string) string, value ...interface{}) {
var b bytes.Buffer
xml.Escape(w&b, []byte(value[0].(string)s))
return b.String()
}
 
func main() {
xt := template.MustParseNew("").Funcs(tmpl, template.FormatterMapFuncMap{"xml": xmlFormatterxmlEscapeString})
xttemplate.ExecuteMust(osxt.Stdout, crmsParse(tmpl))
if err := xt.Execute(os.Stdout, crms); err != nil {
fmt.Println(err)
{.end}
}</lang>
Output:
1,707

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.