FAQ
Hi,

I'd like to map the following.

<Element Size="100 200"/>

into the following struct

type Element struct {
Size []float64
}


Can anyone help.

Golan

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Ross Light at Feb 1, 2013 at 5:48 pm
    I answered a similar question on SO recently:

    http://stackoverflow.com/a/13795905/111866

    Only difference is that you will need to tag your struct with:

    type Element struct {
    Size []float64 `xml:",attr"`
    }

    Ross Light
    http://www.zombiezen.com/contact/

    On Fri, Feb 1, 2013 at 2:27 AM, wrote:
    Hi,

    I'd like to map the following.

    <Element Size="100 200"/>

    into the following struct

    type Element struct {
    Size []float64
    }


    Can anyone help.

    Golan

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Golan Trevize at Feb 3, 2013 at 9:26 am
    Hi Ross,

    This is what I tried and it still didn't work.

    http://play.golang.org/p/JAHA5KPFMR

    If I changed Size to:
    Size string `xml:",attr"`

    then it's okay but it isn't what I'm looking for.

    Note: The post in stackoverflow is interesting and I can see
    myself referring to it when I need to marshal.

    Thanks,
    Golan

    On Friday, February 1, 2013 7:48:04 PM UTC+2, Ross Light wrote:

    I answered a similar question on SO recently:

    http://stackoverflow.com/a/13795905/111866

    Only difference is that you will need to tag your struct with:

    type Element struct {
    Size []float64 `xml:",attr"`
    }

    Ross Light
    http://www.zombiezen.com/contact/


    On Fri, Feb 1, 2013 at 2:27 AM, <golantr...@gmail.com <javascript:>>
    wrote:
    Hi,

    I'd like to map the following.

    <Element Size="100 200"/>

    into the following struct

    type Element struct {
    Size []float64
    }


    Can anyone help.

    Golan

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Ross Light at Feb 4, 2013 at 12:42 am
    Right, it's not exactly the same, but a similar approach:

    http://play.golang.org/p/7TdvigrA-0

    I agree, until there's a MarshalXML/UnmarshalXML interface, it's not
    ideal, but this pattern has worked fairly well for me.

    Ross Light
    http://www.zombiezen.com/contact/

    On Sun, Feb 3, 2013 at 1:26 AM, Golan Trevize wrote:
    Hi Ross,

    This is what I tried and it still didn't work.

    http://play.golang.org/p/JAHA5KPFMR

    If I changed Size to:
    Size string `xml:",attr"`

    then it's okay but it isn't what I'm looking for.

    Note: The post in stackoverflow is interesting and I can see myself
    referring to it when I need to marshal.

    Thanks,
    Golan

    On Friday, February 1, 2013 7:48:04 PM UTC+2, Ross Light wrote:

    I answered a similar question on SO recently:

    http://stackoverflow.com/a/13795905/111866

    Only difference is that you will need to tag your struct with:

    type Element struct {
    Size []float64 `xml:",attr"`
    }

    Ross Light
    http://www.zombiezen.com/contact/

    On Fri, Feb 1, 2013 at 2:27 AM, wrote:
    Hi,

    I'd like to map the following.

    <Element Size="100 200"/>

    into the following struct

    type Element struct {
    Size []float64
    }


    Can anyone help.

    Golan

    --
    You received this message because you are subscribed to the Google
    Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an
    email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Golan Trevize at Feb 6, 2013 at 5:09 pm
    Hi Ross,

    Thanks for the pattern - I've tried it and it's okay by me.

    Cheers,
    Golan
    On Monday, February 4, 2013 2:42:34 AM UTC+2, Ross Light wrote:

    Right, it's not exactly the same, but a similar approach:

    http://play.golang.org/p/7TdvigrA-0

    I agree, until there's a MarshalXML/UnmarshalXML interface, it's not
    ideal, but this pattern has worked fairly well for me.

    Ross Light
    http://www.zombiezen.com/contact/

    On Sun, Feb 3, 2013 at 1:26 AM, Golan Trevize wrote:
    Hi Ross,

    This is what I tried and it still didn't work.

    http://play.golang.org/p/JAHA5KPFMR

    If I changed Size to:
    Size string `xml:",attr"`

    then it's okay but it isn't what I'm looking for.

    Note: The post in stackoverflow is interesting and I can see myself
    referring to it when I need to marshal.

    Thanks,
    Golan

    On Friday, February 1, 2013 7:48:04 PM UTC+2, Ross Light wrote:

    I answered a similar question on SO recently:

    http://stackoverflow.com/a/13795905/111866

    Only difference is that you will need to tag your struct with:

    type Element struct {
    Size []float64 `xml:",attr"`
    }

    Ross Light
    http://www.zombiezen.com/contact/

    On Fri, Feb 1, 2013 at 2:27 AM, wrote:
    Hi,

    I'd like to map the following.

    <Element Size="100 200"/>

    into the following struct

    type Element struct {
    Size []float64
    }


    Can anyone help.

    Golan

    --
    You received this message because you are subscribed to the Google
    Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send
    an
    email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Tamás Gulácsi at Feb 1, 2013 at 7:09 pm
    Sorry, Golan just can't wirhhold the questio: are you really born as Golan Trevize? (
    http://asimov.wikia.com/wiki/Golan_Trevize)

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedFeb 1, '13 at 2:45p
activeFeb 6, '13 at 5:09p
posts6
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase