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

Closed
nemith opened this Issue Dec 5, 2013 · 3 comments

Comments

Projects
None yet
6 participants
@nemith
Copy link
Contributor

nemith commented Dec 5, 2013

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. http://play.golang.org/p/o20RjaRdtQ
2.
3.

What is the expected output?

It would be preferable to get
<RPCElementTarget><running/></RPCElementTarget>

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:
<RPCElementTarget><running></running></RPCElementTarget>

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

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.
@minux

This comment has been minimized.

Copy link
Member

minux commented Dec 5, 2013

Comment 1:

Labels changed: added repo-main.

@davecheney

This comment has been minimized.

Copy link
Contributor

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
coding.

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

@SamWhited

This comment has been minimized.

Copy link
Member

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.