-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
encode/xml: Support XML namespaces #6517
Labels
Comments
colon is a reserved character in the XML spec[1], it denotes a namespace. The go XML package does not handle namespaces so your example is equivalent to http://play.golang.org/p/UbFjiHRhZt [1] http://www.w3.org/TR/REC-xml/#NT-Name |
XML name spaces are already supported. golang.org/pkg/encoding/xml "Package xml implements a simple XML 1.0 parser that understands XML name spaces." However, your example at http://play.golang.org/p/J98usiO91P is not valid XML. In <ns:tag>, the ns is not an absolute name. It is a relative reference to a URL defined earlier in the XML. For example, these two stanzas are semantically equivalent XML <outer xmlns:pers="http://my.url/"> <pers:on>Hello</pers:on> </outer> <outer xmlns:foo="http://my.url/"> <foo:on>Hello</foo:on> </outer> A corrected version of the example is http://play.golang.org/p/lqxkM3MDeD. If you must pass malformed XML to the parser, it will cope and assume that the "URL" is the prefix itself, in which case you can do something like http://play.golang.org/p/DXosg_tjfj. However, that is more fragile, because it does not understand alternate encodings of the same XML (using different prefixes but the same underlying URL) and I don't recommend it. Status changed to WorkingAsIntended. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by oltoko:
The text was updated successfully, but these errors were encountered: