FAQ
I am trying to take the following bit of XML and Unmarshal then marshal it
again just to show I have the structs for it right.

http://play.golang.org/p/u7QJTs-994

I'm having trouble with the value section specifically these bits are
getting lost xml:lang="es" which tell me which language this has been
translated into.

<?xml version="1.0" encoding="utf-8"?>
<appStrings xmlns="http://schemas.company.net/2010-xdr-AppString-1.0">
<item name="ui.app.com.docmanager.main.myLibrary">
<value>My Library</value>
</item>
<item name="user.view.request.details.timetorespond">
<value>Time to Respond</value>
<value xml:lang="he">זמן להגיב</value>
</item>
<item name="user.view.request.details.takeOffHold">
<value>Taken off hold</value>
<value xml:lang="es">Tomado retenida</value>
<value xml:lang="he">המריא המתנה</value>
</item>
</appstring>


Can anyone point out what I am doing wrong please ?

--
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/d/optout.

Search Discussions

  • Shawn Milochik at Feb 5, 2016 at 8:26 pm
    Works: http://play.golang.org/p/rN_Tp3IyOS

    The problem, as I understand it, is getting both the text in the <value>
    element and the attribute (such as lang="es") into a single struct.

    I think the main problem was the Value struct you made; it implies that
    <value> has a sub-element also named value. You need to use
    `xml:",chardata"` to get that. Which I didn't know and had to look up in
    the docs, so thanks for helping me learn something.

    --
    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/d/optout.
  • Alexander Kapshuk at Feb 5, 2016 at 8:29 pm

    On Fri, Feb 5, 2016 at 9:53 PM, Jeffrey Smith wrote:
    I am trying to take the following bit of XML and Unmarshal then marshal it
    again just to show I have the structs for it right.

    http://play.golang.org/p/u7QJTs-994

    I'm having trouble with the value section specifically these bits are
    getting lost xml:lang="es" which tell me which language this has been
    translated into.

    <?xml version="1.0" encoding="utf-8"?>
    <appStrings xmlns="http://schemas.company.net/2010-xdr-AppString-1.0">
    <item name="ui.app.com.docmanager.main.myLibrary">
    <value>My Library</value>
    </item>
    <item name="user.view.request.details.timetorespond">
    <value>Time to Respond</value>
    <value xml:lang="he">זמן להגיב</value>
    </item>
    <item name="user.view.request.details.takeOffHold">
    <value>Taken off hold</value>
    <value xml:lang="es">Tomado retenida</value>
    <value xml:lang="he">המריא המתנה</value>
    </item>
    </appstring>


    Can anyone point out what I am doing wrong please ?

    --
    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/d/optout.
    With error checking added to your 'xml.Unmarshal' call, I get:
    error: XML syntax error on line 15: element <appStrings> closed by </appstring>

    See below:
    http://play.golang.org/p/ea2MyWjzpK

    --
    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/d/optout.
  • Matt Harden at Feb 5, 2016 at 9:58 pm
    http://play.golang.org/p/jH67WfoU9c
    On Fri, Feb 5, 2016 at 12:29 PM Alexander Kapshuk wrote:

    On Fri, Feb 5, 2016 at 9:53 PM, Jeffrey Smith
    wrote:
    I am trying to take the following bit of XML and Unmarshal then marshal it
    again just to show I have the structs for it right.

    http://play.golang.org/p/u7QJTs-994

    I'm having trouble with the value section specifically these bits are
    getting lost xml:lang="es" which tell me which language this has been
    translated into.

    <?xml version="1.0" encoding="utf-8"?>
    <appStrings xmlns="http://schemas.company.net/2010-xdr-AppString-1.0">
    <item name="ui.app.com.docmanager.main.myLibrary">
    <value>My Library</value>
    </item>
    <item name="user.view.request.details.timetorespond">
    <value>Time to Respond</value>
    <value xml:lang="he">זמן להגיב</value>
    </item>
    <item name="user.view.request.details.takeOffHold">
    <value>Taken off hold</value>
    <value xml:lang="es">Tomado retenida</value>
    <value xml:lang="he">המריא המתנה</value>
    </item>
    </appstring>


    Can anyone point out what I am doing wrong please ?

    --
    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/d/optout.
    With error checking added to your 'xml.Unmarshal' call, I get:
    error: XML syntax error on line 15: element <appStrings> closed by
    </appstring>

    See below:
    http://play.golang.org/p/ea2MyWjzpK

    --
    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/d/optout.
    --
    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/d/optout.
  • Jeffrey Smith at Feb 5, 2016 at 10:57 pm
    Thanks for all the responses. I spent a few hours bashing my head against
    this :-)
    On Friday, February 5, 2016 at 9:58:15 PM UTC, Matt Harden wrote:

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

    On Fri, Feb 5, 2016 at 12:29 PM Alexander Kapshuk <alexande...@gmail.com
    <javascript:>> wrote:
    On Fri, Feb 5, 2016 at 9:53 PM, Jeffrey Smith
    <jeffreys...@gmail.com <javascript:>> wrote:
    I am trying to take the following bit of XML and Unmarshal then marshal it
    again just to show I have the structs for it right.

    http://play.golang.org/p/u7QJTs-994

    I'm having trouble with the value section specifically these bits are
    getting lost xml:lang="es" which tell me which language this has been
    translated into.

    <?xml version="1.0" encoding="utf-8"?>
    <appStrings xmlns="http://schemas.company.net/2010-xdr-AppString-1.0">
    <item name="ui.app.com.docmanager.main.myLibrary">
    <value>My Library</value>
    </item>
    <item name="user.view.request.details.timetorespond">
    <value>Time to Respond</value>
    <value xml:lang="he">זמן להגיב</value>
    </item>
    <item name="user.view.request.details.takeOffHold">
    <value>Taken off hold</value>
    <value xml:lang="es">Tomado retenida</value>
    <value xml:lang="he">המריא המתנה</value>
    </item>
    </appstring>


    Can anyone point out what I am doing wrong please ?

    --
    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/d/optout.
    With error checking added to your 'xml.Unmarshal' call, I get:
    error: XML syntax error on line 15: element <appStrings> closed by
    </appstring>

    See below:
    http://play.golang.org/p/ea2MyWjzpK

    --
    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/d/optout.
    --
    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/d/optout.
  • Sam Whited at Feb 9, 2016 at 12:07 am

    On Fri, Feb 5, 2016 at 1:53 PM, Jeffrey Smith wrote:
    I'm having trouble with the value section specifically these bits are
    getting lost xml:lang="es" which tell me which language this has been
    translated into.
    One quick note: the tag on your Lang attribute should be:
    `xml:"http://www.w3.org/XML/1998/namespace lang,attr"`

    Which will correctly output with the "xml:" prefix.

    Best,
    Sam



    --
    Sam Whited
    pub 4096R/54083AE104EA7AD3
    https://blog.samwhited.com

    --
    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/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedFeb 5, '16 at 7:53p
activeFeb 9, '16 at 12:07a
posts6
users5
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase