如何使用XMLBeam映射两个相似的XML元素? [英] How to map two similar XML Element using XMLBeam?

查看:89
本文介绍了如何使用XMLBeam映射两个相似的XML元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是XML的格式,因此我很难抓住第二个实例:

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>

从上面,我只能获取第一个实例的详细信息(名称1),因为除了<TextField3>###</TextField3>

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>

什么是正确的@XBRead格式?

推荐答案

从您的答案中我想您需要一个字符串列表:

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

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

这篇关于如何使用XMLBeam映射两个相似的XML元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆