FAQ
Hello,

I am trying to decode an XML document containing elements named "content"
and "media:content". I'm not sure is there is a different way of writing
names in the tag field, but the code below gives me a name conflict error
although "media:content" is in a different namespace.

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

Regards,

-Emre Kazdagli

--
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

  • Clbanning at Jun 23, 2013 at 12:50 pm
    With the "media:content" tag, the xml.Decoder strips "media:" and sees it
    as "content". xml.Decoder.Token is treats ":" as a NameStartChar even
    when it occurs as a NameChar; it does properly decode ":media:content".
      You should probably file a bug report, since according to spec
    NameStartChar can be NameChar.
    On Friday, June 21, 2013 9:12:46 PM UTC-5, Emre Kazdağlı wrote:

    Hello,

    I am trying to decode an XML document containing elements named "content"
    and "media:content". I'm not sure is there is a different way of writing
    names in the tag field, but the code below gives me a name conflict error
    although "media:content" is in a different namespace.

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

    Regards,

    -Emre Kazdagli
    --
    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.
  • Clbanning at Jun 23, 2013 at 3:00 pm
    The xml.Decoder treats a ':' in the name as delimiting the namespace.
      Thus, "media:content" returns
                d.Space = "media"
                d.Local = "content"

    Here's the relevant method from go/src/pkg/encoding/xml/xml.go (line 1022f)
    -

    // Get name space name: name with a : stuck in the middle.
    // The part before the : is the name space identifier.
    func (d *Decoder) nsname() (name Name, ok bool) {
        s, ok := d.name()
        if !ok {
           return
        }
        i := strings.Index(s, ":")
        if i < 0 {
           name.Local = s
        } else {
           name.Space = s[0:i]
           name.Local = s[i+1:]
        }
        return name, true
    }

    On Friday, June 21, 2013 9:12:46 PM UTC-5, Emre Kazdağlı wrote:

    Hello,

    I am trying to decode an XML document containing elements named "content"
    and "media:content". I'm not sure is there is a different way of writing
    names in the tag field, but the code below gives me a name conflict error
    although "media:content" is in a different namespace.

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

    Regards,

    -Emre Kazdagli
    --
    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
postedJun 22, '13 at 5:19a
activeJun 23, '13 at 3:00p
posts3
users2
websitegolang.org

2 users in discussion

Clbanning: 2 posts Emre Kazdağlı: 1 post

People

Translate

site design / logo © 2022 Grokbase