Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: Xpath parsing

  1. #1
    Join Date
    Jul 2008
    Posts
    3

    Default Xpath parsing

    Hi,

    i have XML file like this:

    HTML Code:
    <userlist>
      <user id="6546">
        <firstname>John</username>
        <lastname>Travolta</lastname>
        <license>
          <license_type>Personal</license_type>
          <license_no>dsfd65sf4sd65f4</license_no>
          <date_expire>1977-05-02</date_expire>
        </license>
        <license>
          <license_type>Personal</license_type>
          <license_no>ffffff46546a6b</license_no>
          <date_expire>1977-05-02</date_expire>
        </license>
      </user>
      <user id="6547">
        <firstname>Obcan</username>
        <lastname>Havel</lastname>
        <license>
          <license_type>Goverment</license_type>
          <license_no>dsfd65f45d65f4</license_no>
          <date_expire>1977-05-02</date_expire>
        </license>
        <license>
          <license_type>Goverment</license_type>
          <license_no>aaffff46546a6b</license_no>
          <date_expire>1977-05-02</date_expire>
        </license>
      </user>
    </userlist>
    I need get back all records about all licenses with their user id.

    In XPATH is /userlist/user/license
    i have enabled name space aware
    and in fields is:

    license_type license_type Node
    license_no license_no Node
    date_expire date_expire Node
    id /userlist/user/@id Node

    but in output is id as value from first id row

    license_type,license_no,date_expire,id
    Personal,dsfd65sf4sd65f4,1977-05-02,6546
    Personal,ffffff46546a6b,1977-05-02,6546
    Goverment,aaffff46546a6b,1977-05-02,6546

    (example in attachment), Kettle 3.2.0-GA

    thanks guys
    Attached Files Attached Files

  2. #2
    Join Date
    Apr 2008
    Posts
    4,696

    Default

    Try changing the path for id from:
    /userlist/user/@id
    to
    ../@id

    From your sample files, I was able to get the output you wanted when I made that change.

  3. #3
    Join Date
    Jul 2008
    Posts
    3

    Smile Thanks

    it works!
    Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.