Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html/template: escape xmldesc as <?xml #3133

Closed
ukai opened this issue Feb 26, 2012 · 3 comments
Closed

html/template: escape xmldesc as <?xml #3133

ukai opened this issue Feb 26, 2012 · 3 comments

Comments

@ukai
Copy link
Contributor

ukai commented Feb 26, 2012

What steps will reproduce the problem?
package main
import (
    "html/template"
    "os"
)
func main() {
    t1, _ := template.New("xml").Parse(`<?xml version="1.0"?><feed></feed>`)
    t1.Execute(os.Stdout, nil)
}

What is the expected output?

<?xml vesion="1.0"?><feed></feed>

What do you see instead?

&lt;?xml version="1.0"?><feed></feed>

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

linux

Which revision are you using?  (hg identify)

767b6229d4dc tip

Please provide any additional information below.

I'm not sure it's ok to use html/template for xml generation, but encoding/xml provides
only xml parsing, and we may need lots of escape with text/template.
@robpike
Copy link
Contributor

robpike commented Feb 26, 2012

Comment 1:

html/template is not meant for XML. You'll have to use text/template and do the
escaping, annoying though that is.

Status changed to WorkingAsIntended.

@rsc
Copy link
Contributor

rsc commented Feb 28, 2012

Comment 2:

I would also note that encoding/xml *does* write XML.
http://weekly.golang.org/pkg/encoding/xml/#example_MarshalIndent

@ukai
Copy link
Contributor Author

ukai commented Feb 29, 2012

Comment 3:

oh, why I couldn't find this..
thanks!

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants