FAQ
Currently working on an XSD package for Go (
https://github.com/metaleap/go-xsd/ ) and wondering about the following:

We can simply map known attributes to string fields:

type Person struct {
Email string `xml:"email,attr"`
}

I admit it's rare, but in some XML use-cases, there may be free-form
attribute usage and it would be great to be able to define a map field that
could collect all attribute key-value pairs, such as:

type Record struct {
Atts map[string]string `xml:",attrs"`
}

Anything like this currently possible with encoding/xml?

--

Search Discussions

  • Sarah09124 at Nov 7, 2012 at 9:07 pm
    the only experience I have with xml mapping was through using a data
    mapping tool (http://www.liquid-technologies.com/xmldatamapper.aspx)
    On Wednesday, November 7, 2012 7:23:45 AM UTC, Philipp Schumann wrote:

    Currently working on an XSD package for Go (
    https://github.com/metaleap/go-xsd/ ) and wondering about the following:

    We can simply map known attributes to string fields:

    type Person struct {
    Email string `xml:"email,attr"`
    }

    I admit it's rare, but in some XML use-cases, there may be free-form
    attribute usage and it would be great to be able to define a map field that
    could collect all attribute key-value pairs, such as:

    type Record struct {
    Atts map[string]string `xml:",attrs"`
    }

    Anything like this currently possible with encoding/xml?
    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 7, '12 at 7:23a
activeNov 7, '12 at 9:07p
posts2
users2
websitegolang.org

2 users in discussion

Sarah09124: 1 post Philipp Schumann: 1 post

People

Translate

site design / logo © 2022 Grokbase