xml parsing in golang with chardata

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

xml parsing in golang with chardata

问题

请看一下这个链接:https://play.golang.org/p/RioZSwO6WB,我在解析后无法获取用户名,程序运行正常,请帮忙看一下。

提前感谢。

英文:

https://play.golang.org/p/RioZSwO6WB ,please look into it i am not able to get the username after parsing ,program in working fine ,please look into it.

thanks in advance

答案1

得分: 2

在你的结构体中,你说 XML 节点叫做 username,但实际上它叫做 userName

只需要将这部分代码替换为:

Username CData `xml:"userName"`

然后应该就可以正常工作了。

英文:

In your struct you're saying that the xml node is called username when it's actually called userName.

Simply replace this:

Username CData `xml:"username"`

With:

Username CData `xml:"userName"`

And it should work fine.

huangapple
  • 本文由 发表于 2015年11月17日 18:26:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/33754545.html
匿名

发表评论

匿名网友

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

确定