如何判断是否找到了一个空的XML节点?

huangapple go评论132阅读模式
英文:

How to tell if an empty XML node has been found?

问题

我有一个像这样的XML:

<list>
<entry><string>...</string><string>...</string></entry>
<entry><string>...</string><string></string></entry>
<entry><string>...</string><null/></entry>
<entry><string>...</string><string>...</string><null/></entry>
</list>

如何判断我是否有一个<null/>元素?这是我试图处理的结构:

type Entry struct {
    Values []string `xml:"string"`
    Null   string   `xml:"null"`
}
英文:

I have XML like this:

<list>
<entry><string>...</string><string>...</string></entry>
<entry><string>...</string><string></string></entry>
<entry><string>...</string><null/></entry>
<entry><string>...</string><string>...</string><null/></entry>
</list>

How to tell that I had a <null/> element? This is the struct I'm trying to work with:

type Entry struct {
    Values []string `xml:"string"`
    Null   string   `xml:"null"`
}

答案1

得分: 1

好的,以下是翻译好的内容:

好的,那真是尴尬 :)

    type Entry struct {
        Values []string `xml:"string"`
        Nulls  []string `xml:"null"`
    }
英文:

OK that was embarrassing 如何判断是否找到了一个空的XML节点?

type Entry struct {
    Values []string `xml:"string"`
    Nulls  []string `xml:"null"`
}

huangapple
  • 本文由 发表于 2013年11月27日 00:11:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/20222213.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定