How to map two similar XML Element using XMLBeam?

送分小仙女□ 提交于 2019-12-12 03:38:30

问题


This is the format of the XML so it is difficult for me to grab the 2nd instance:

<sec2_Ind>
 <SectC_EntyType>
  <TextField3>1</TextField3>
 </SectC_EntyType>
 <nameInfo>
  <subName>
   <fName>Name 1</fName>
  </subName>
 </nameInfo>
 <SectC_EntyType>
  <TextField3>2</TextField3>
 </SectC_EntyType>
 <nameInfo>
  <subName>
   <fName>Name 2</fName>
  </subName>
 </nameInfo>
<sec2_Ind>

From above, I am only able to get the 1st instance details (Name 1) as the elements does not have unique identifier except for <TextField3>###</TextField3>

What is the proper @XBRead format as well?


回答1:


From your answer I guess that you want a list of Strings:

 @XBRead("//(TextField3 | fName)")
 List<String> getNames();


来源:https://stackoverflow.com/questions/43831634/how-to-map-two-similar-xml-element-using-xmlbeam

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!