英文:
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
type Entry struct {
Values []string `xml:"string"`
Nulls []string `xml:"null"`
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论