如何设置正确的xpath

时间:2013-01-25 12:15:49

标签: xml xpath kettle

我希望在Keetle Spoon中生成列表输出:

system_name,productname

示例:

JOHN Adobe Reader XI (11.0.01)
JOHN D3DX10
JOHN Google Drive
JOHN Adobe Flash Player 11 ActiveX
JOHN Adobe Flash Player 11 Plugin

来自xml文件:

<computer>
 <system name="JOHN" />
 <operatingsystem name="Microsoft Windows 7 Professional " servicepack="Service Pack 1" />
 <windowscomponents>
  <component name="Windows Media Player (from Start Menu and Desktop)" class="2200" classname="" level="1" />
 </windowscomponents>
 <installedapplications>
  <msiapplication productname="Adobe Reader XI (11.0.01)" vendor="Adobe Systems Incorporated" version="11.0.01" installdate="20130111" />
  <msiapplication productname="D3DX10" vendor="Microsoft" version="15.4.2368.0902" installdate="20121219" />
  <msiapplication productname="Google Drive" vendor="Google, Inc." version="1.7.4018.3496" installdate="20130108" />
  <regapplication productname="Adobe Flash Player 11 ActiveX" version="11.5.502.146" />
  <regapplication productname="Adobe Flash Player 11 Plugin" version="11.5.502.146" />
 </installedapplications>
</computer>

我使用的设置: Loop XPath /computer

字段:

  1. system/@name
  2. installedapplications/msiapplication/@productname
  3. installedapplications/regapplication/@productname
  4. 但我只获得行:

    JOHN Adobe Reader XI (11.0.01)
    JOHN Adobe Flash Player 11 ActiveX
    

1 个答案:

答案 0 :(得分:0)

我所知道的关于水壶汤的所有内容都来自回答你之前的问题,但我相信你应该使用以下内容:

Loop XPath /computer/installedapplications/*

字段

../../system/@name
@productname