鉴于以下我无法控制的 XML: <Stuff> <SomeData> <SomeDataStuff> <AccountDetails> <Person xsi:nil="true" /> <Person xsi:nil="true" /> </AccountDetails> <CandidateDetails> <Candidate xsi:nil="true" /> <Candidate xsi:nil="true" /> </CandidateDetails> </SomeDataStuff> </SomeData> </Stuff>我可以使用以下内容解组,可以稍微简化一下吗? type Stuff struct { XMLName xml.Name SomeData SomeData } type SomeData struct { XMLName xml.Name SomeDataStuff SomeDataStuff }type SomeDataStuff struct { AccountDetails AccountDetails `xml:"AccountDetails"` CandidateDetails CandidateDetails `xml:"CandidateDetails"`} type AccountDetails struct { Person []Person } type CandidateDetails struct { Candidate []Candidate } type Person struct { ... } type Candidate struct { ... } 我不担心编组,只是解组。我真正需要的只是一个Personand数组,而Candidate不是整个嵌套的无意义结构序列
1 回答
- 1 回答
- 0 关注
- 211 浏览
添加回答
举报
0/150
提交
取消