0 xml xpath pentaho nodes kettle
我有一个XML以下面提到的格式.我在pentaho中使用Get XML来解析它.但我无法获得获得所有价值的正确途径.我想要' custom-attributes '的所有值.
它只给了我第一个属性的价值.ie仅用于'性'.任何人都可以帮我如何获取其他自定义属性的值.
我将' LoopXpath '设置为: -/names/name
在字段选项卡中按" 获取字段 "后.我自动在Fields选项卡中获取自定义属性xpath,如下所述: - 它只给出'sex'的值.
Name |Xpath |Element | ResultType |Type
----------------------------------------------------------------------------------------------
custom-attributes |custom-attributes/custom-attribute |Node |Value of |String
<names>
<name>
<firstname>ABCDEH</firstname>
<lastname>JKLAM</lastname>
<custom-attributes>
<custom-attribute attribute-id="sex">male</custom-attribute>
<custom-attribute attribute-id="height">169</custom-attribute>
<custom-attribute attribute-id="weight">78</custom-attribute>
<custom-attribute attribute-id="dateofbirth">09/09/1990</custom-attribute>
<custom-attribute attribute-id="occupation">engineer</custom-attribute>
</custom-attributes>
</name>
</names>
Run Code Online (Sandbox Code Playgroud)
最后我想要一个如下所述的单行: -
firstname lastname sex height weight dateofbirth occupation
ABCDEH JKLAM male 160 78 09/09/1990 engineer
Run Code Online (Sandbox Code Playgroud)
有谁可以帮助我
我不确定你在代码中做了什么.首先在步骤的" 循环XPATH "设置部分中,定义父节点路径而不是" 自定义属性 "路径(如上所述),如下所示:
/names/name/custom-attributes//*
Run Code Online (Sandbox Code Playgroud)
其次,当你获得字段属性即" 自定义属性 "时,你需要指定XPATH为' .'(点).这将执行属性值的递归.检查下图:

最后,您将获得递归数据:

我在这里放了一个示例代码.请检查出来参考.
希望能帮助到你 :)
| 归档时间: |
|
| 查看次数: |
4403 次 |
| 最近记录: |