-
Notifications
You must be signed in to change notification settings - Fork 18k
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: field tag cleanup #2426
Labels
Milestone
Comments
Tags aren't symmetrical either. The following code panics: package main import ( "fmt" "encoding/xml" "bytes" ) type Foo struct { XMLName xml.Name `xml:"foo"` X int `xml:"y"` } func main() { var b bytes.Buffer xml.Marshal(&b, &Foo{ X: 56, }) var x Foo err := xml.Unmarshal(&b, &x) if err != nil { fmt.Printf("error: %v\n", err) return } if x.X != 56 { panic("unexpected unmarshalled value") } } |
I think I'll just put it here. A small feature request for future "xml" package versions. I had a need to filter xml elements by their namespace, consider this example: <package> <include name="GObject"/> <include name="Gtk"/> <c:include name="glib-object.h"/> <c:include name="gtk/gtk.h"/> </package> So, I would like to unmarshal that into a struct with two arrays for each namespace: type Package struct { Includes []Include CIncludes []Include } And currently such thing is impossible as far as I can see. Also attributes may have namespaces as well. Parser understands that, but there is no way to use attribute namespaces with struct tags. E.g.: <method name="get_comments" c:identifier="gtk_about_dialog_get_comments" version="2.6"> ... </method> Maybe though attributes cannot have matching local names in xml, I don't know. P.S. It's a shame that there is so much real world data in this perverted format. |
Owner changed to @niemeyer. Status changed to Started. |
This issue was closed by revision 1627b46. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: