我有以下 XML 并使用kettle spoon Get XML Data来提取:
<Company cname="ABC">
<Staffs>
<Manager mname="John">
<Subordinate sname="Apple">
<PhoneNo>11111111</PhoneNo>
</Subordinate>
<Subordinate sname="Becky">
<PhoneNo>22222222</PhoneNo>
</Subordinate>
</Manager>
<Manager mname="Peter">
<Subordinate sname="Cathy">
<PhoneNo>33333333</PhoneNo>
</Subordinate>
<Subordinate sname="Doris">
<PhoneNo>44444444</PhoneNo>
</Subordinate>
</Manager>
</Staffs>
</Company>
如果我将Loop XPath设置为/Company/Staffs/Manager/Subordinate,我得到的经理名称不正确(所有经理都是 John!)。
Mname: ../../*[name()='Manager']/@*[name()='mname']
Sname: @*[name()='sname']
PhoneNo: *[name()='PhoneNo']
|#|Mname|Sname|PhoneNo |
|-+-----+-----+--------|
|1|John |Apple|11111111|
|2|John |Becky|22222222|
|3|John |Cathy|33333333|
|4|John |Doris|44444444|
请帮忙,如何获得正确的经理姓名?
------------------------
|#|Mname|Sname|PhoneNo |
|-+-----+-----+--------|
|1|John |Apple|11111111|
|2|John |Becky|22222222|
|3|Peter|Cathy|33333333|
|4|Peter|Doris|44444444|
------------------------