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

encoding/xml: No way of creating self terminating nodes with MarshalXML #6896

nemith opened this Issue Dec 5, 2013 · 3 comments


None yet
6 participants
Copy link

nemith commented Dec 5, 2013

What steps will reproduce the problem?
If possible, include a link to a program on

What is the expected output?

It would be preferable to get

What do you see instead?

There is no way to do self terminating elements.  The best we can do is to do a start
and end element with no chardata.  This does not work for my application.  The closest
output is:

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

Which operating system are you using?
OS X 10.9

Which version are you using?  (run 'go version')
go version go1.2 darwin/amd64

Please provide any additional information below.

This comment has been minimized.

Copy link

minux commented Dec 5, 2013

Comment 1:

Labels changed: added repo-main.


This comment has been minimized.

Copy link

davecheney commented Feb 5, 2014

Comment 2:

The xml package does not handle this case at the moment. the XML rfc says that
<element></element> and <element /> are semantically identical, but I
understand that this is sometimes lost in the sea of interoperability.
One solution to this problem would be to add an extra attribute to the struct tag to
indicate that this tag should be encoded with the empty element form.
If you want to tackle this, please remember to discuss your design before starting

Labels changed: added release-none.

Status changed to Accepted.

@nemith nemith added accepted labels Feb 5, 2014

@rsc rsc added this to the Unplanned milestone Apr 10, 2015

@rsc rsc removed release-none labels Apr 10, 2015


This comment has been minimized.

Copy link

SamWhited commented Oct 2, 2017

Duplicate of #21399 (this issue is older, but someone has a change against the new issue, so I'm closing this one). Thanks!

@SamWhited SamWhited closed this Oct 2, 2017

@golang golang locked and limited conversation to collaborators Oct 2, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.