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