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: Issue with unmarshal of XML to struct when XML elements have namespace #26859

Closed
rambhavaraju opened this Issue Aug 8, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@rambhavaraju
Copy link

rambhavaraju commented Aug 8, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

v 1.10

Does this issue reproduce with the latest release?

not sure

What operating system and processor architecture are you using (go env)?

Windows/linux

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
https://play.golang.org/p/lFP3IBix_O5

What did you expect to see?

I was expecting the XML to be converted to the struct definiton

What did you see instead?

Error response.

@mvdan

This comment has been minimized.

Copy link
Member

mvdan commented Aug 8, 2018

There's lots of previous issues about encoding/xml's support of namespaces. Are you positive this is not a duplicate?

@rambhavaraju

This comment has been minimized.

Copy link
Author

rambhavaraju commented Aug 8, 2018

Thanks @mvdan for your response. I did search in all the issues reported and did try most of the things suggested but none seem to work. If you could point me to one very close to what i have listed here I would appreciate it. Namespace is pretty much there in every element on the xml i shared in my example and the problem is that unmarshal is not happening.

@mvdan

This comment has been minimized.

Copy link
Member

mvdan commented Aug 8, 2018

Note that I'm not saying there is a fix or workaround for this. Namespaces have been known to be broken in encoding/xml for a while. My point is that this simple case is very likely covered by one of the existing issues on the tracker already.

@bcmills

This comment has been minimized.

Copy link
Member

bcmills commented Aug 9, 2018

You have an extra space before the first " in xml: "serv bodyContent".

Fixing that, it seems to unmarshal as expected: https://play.golang.org/p/MUFRZdWT1LK

Please let us know if that doesn't fix your issue.

@bcmills bcmills closed this Aug 9, 2018

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