英文:
get all values of specific xml field
问题
有没有一种方法可以获取 XML 文件中特定字段名称的所有值?该字段在不同的嵌套级别中出现多次,而且我事先不知道它可能在文档中的哪个位置。
英文:
Is there a way to get all values for specific field name in xml file? This field appears multiple times in different nested levels, and I don't know in advance where it may be in document.
答案1
得分: 1
使用encoding/xml中的Decoder,并使用func (*Decoder) Token迭代你的XML。在迭代过程中,检查具有所需Name的StartElement。
英文:
Use a Decoder from encoding/xml and iterate over your XML with func (*Decoder) Token. While iterating check for StartElements with the desired Name.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论