-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: XML tag name that consist of ':' doesn't get umarshaled properly #62075
Comments
CC @rsc, @ianlancetaylor. |
@ormergi in the struct tag the namespace separator is space, i.e. |
@jupenur thanks for the feedback
Instead of:
|
why aren't you using |
We just hit this as well. I can't speak to @ormergi's case, but we are generating about a thousand Go types from XSD for an unfortunately picky downstream API. That API appears to require namespace prefixes rather than xmlns attributes on all but the top level. Using xml.Name creates exactly those xmlns attributes. The only way we've found to marshal attributes with namespace prefixes is to put the prefix in the XML tag like Related: |
Has there been any progress on this? |
My workaround using I must to say it's very dirty and not working for many cases, but it works for me. Hope it'll be helpful for someone :) |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Reproduces using go 1.21 with go.dev/play
What operating system and processor architecture are you using (
go env
)?go version go1.19.9 linux/amd64
go env
OutputWhat did you do?
Umarshaling XML to a struct that has attribute with XML tag whos name consist of
:
wont unmarshal correctly and end up empty.For example:
The
XmlNs
attribute end up with empty string.Reproducer https://go.dev/play/p/5l9WHxVBO5S
What did you expect to see?
I expect the
XmlNs
attribute to umarshal correctly and wont end up empty.What did you see instead?
The
XmlNs
attribute end up empty.The text was updated successfully, but these errors were encountered: