Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: Unable to get XML data of intermediate level

  1. #1
    Join Date
    Nov 2013
    Posts
    382

    Default Unable to get XML data of intermediate level

    I'm trying to read a three-level XML file:

    HTML Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <CAB>
    <NUMPED>ped1</NUMPED>
    <LINALB>
    <REFPROV>prov1</REFPROV>
    <LOTE>
    <NUMLOTE>lote1</NUMLOTE>
    </LOTE>
    </LINALB>
    <LINALB>
    <REFPROV>prov2</REFPROV>
    <LOTE>
    <NUMLOTE>lote2</NUMLOTE>
    </LOTE>
    </LINALB>
    </CAB>
    Loop XPath: /CAB/LINALB/LOTE

    No problem reading the detail field
    XPath: NUMLOTE

    No problem reading the CAB field
    XPath: //NUMPED

    But no way to get the correct /LINALB data. I tried:

    XPath: /REFPROV -> I get a null value
    XPath: /CAB/LINALB/REFPROV -> I get "prov1" for all lines instead of the correct "prov1" on the first line and "Prov2" on the second one.
    Xpath: //REFPROV -> I get "prov1" for all lines instead of the correct "prov1" on the first line and "Prov2" on the second one (I expected a null or an error on this one ...)

    Any idea what I'm doing wrong?

    Thks

  2. #2
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    /CAB/LINALB should be your Loop XPath.
    So long, and thanks for all the fish.

  3. #3
    Join Date
    Nov 2013
    Posts
    382

    Default

    Quote Originally Posted by marabu View Post
    /CAB/LINALB should be your Loop XPath.
    And how do I get the low level (LOTE) data if my Loop XPath is a higher level? I need a line for every LOTE level.

    Maybe my data example was too simple ...

    HTML Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <CAB>
    <NUMPED>ped1</NUMPED>
    <LINALB>
    <REFPROV>prov1</REFPROV>
    <LOTE>
    <NUMLOTE>lote1 v1</NUMLOTE>
    </LOTE>
    <LOTE>
    <NUMLOTE>lote1 v2</NUMLOTE>
    </LOTE>
    </LINALB>
    <LINALB>
    <REFPROV>prov2</REFPROV>
    <LOTE>
    <NUMLOTE>lote2 v1</NUMLOTE>
    </LOTE>
    <LOTE>
    <NUMLOTE>lote2 v2</NUMLOTE>
    </LOTE>
    </LINALB>
    <LINALB>
    <REFPROV>prov3</REFPROV>
    <LOTE>
    <NUMLOTE>lote3</NUMLOTE>
    </LOTE>
    </LINALB>
    </CAB>
    I expect 5 lines:

    ped1,prov1,lote1 v1
    ped1,prov1,lote1 v2
    ped1,prov2,lote2 v1
    ped1,prov2,lote2 v2
    ped1,prov3,lote3

    And I get the expected 5 lines, with the correct NUMPED (ped1) value and NUMLOTE values, but no way to get the correct REFPROV values.
    Last edited by DepButi; 01-17-2017 at 08:46 AM. Reason: Clarify what I get

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

    Default

    Quote Originally Posted by DepButi View Post
    but no way to get the correct REFPROV values.
    You do remember that you can use .. in your XMLPath to go up a level, right?

  5. #5
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    So it's /CAB/LINALB/LOTE, then.


    Name:  217813.png
Views: 27
Size:  23.7 KB
    So long, and thanks for all the fish.

  6. #6
    Join Date
    Nov 2013
    Posts
    382

    Default

    aaaaggggg! Thks, I forgot the double dot

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.