ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Anyone have any experience with XML-into?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Anyone have any experience with XML-into?

    I have this XML
    (I stripped out the xtra junk)
    PHP Code:
    <Table ss:ExpandedColumnCount="3" ss:ExpandedRowCount="238" x:FullColumns="1"
       
    x:FullRows="1" ss:DefaultRowHeight="12.45">
       <
    Column ss:Width="28.8"/>
       <
    Column ss:Width="44.400000000000006"/>
       <
    Column ss:Width="56.4"/>
       <
    Row ss:AutoFitHeight="0" ss:StyleID="s22">
        <
    Cell ss:StyleID="s23"><Data ss:Type="String">clock</Data></Cell>
        <
    Cell ss:StyleID="s23"><Data ss:Type="String">dedcode</Data></Cell>
        <
    Cell ss:StyleID="s23"><Data ss:Type="String">dedcurrent</Data></Cell>
       </
    Row>
       <
    Row ss:AutoFitHeight="0">
        <
    Cell><Data ss:Type="Number">1000</Data></Cell>
        <
    Cell><Data ss:Type="String">SAVE</Data></Cell>
        <
    Cell><Data ss:Type="Number">500</Data></Cell>
       </
    Row>
       
      </
    Table
    created physical file called savings
    PHP Code:
       *---------------------------------------------------------------       
       *---------------------------------------------------------------       
                 
    R SAVINGSR                                                   
                   CLOCK          5          TEXT
    ('Clock#')                   
                   
    DECODE        10          TEXT('Type')                     
                   
    DEDCURRENT    10          TEXT('Deduction')                
                                                                              
                 
    K CLOCK 
    then tried this code
    PHP Code:
    *************** Beginning of data ***********************************************
     
    //                                                                              
     // Variable Definition                                                          
     //                                                                              
                                                                                     
    d  Savings        ds                  Qualified  dim(500)                        
    d   Clock                        5A                                              
    d   decode                      10A                                              
    d   dedcurrent                  10A                                              
                                                                                     
     
    /Free                                                                           
                                                                                     
       
    //--------------------------------------------------------                    
       // MAIN PROGRAM                                                               
       //--------------------------------------------------------                    
                                                                                     
              
    XML-Into Savings %XML('/xml/save.xml' :                                
                                     
    'case=any ' +                                   
                                     
    ' doc=file path=jamielib/savings' +             
                                  
    ' allowmissing=yes');       
                                                                 
           *
    inlr = *on;                                          
                                                                 
    /
    End-Free 
    What the hell did I do wrong?


    Thanks in advance

    jamie
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

  • #2
    Re: Anyone have any experience with XML-into?

    Did you mean to do this?

    Code:
     <Row ss:AutoFitHeight="0" ss:StyleID="s22"> 
        <Cell ss:StyleID="s23"><Data ss:Type="String">clock</Data></Cell> 
        <Cell ss:StyleID="s23"><Data ss:Type="String">[SIZE=4]dedcode[/SIZE]</Data></Cell> 
        <Cell ss:StyleID="s23"><Data ss:Type="String">dedcurrent</Data></Cell> 
       </Row>
    and this

    Code:
    d  Savings        ds                  Qualified  dim(500)                         
    d   Clock                        5A                                               
    d   [SIZE=5]decode[/SIZE]                      10A                                               
    d   dedcurrent                  10A

    Comment


    • #3
      Re: Anyone have any experience with XML-into?

      Jamief,

      What you want is not possible.
      If you want, it's possible to get data between <Data></Data> :

      <Cell ss:StyleID="s23"><Data ss:Type="String">clock</Data></Cell>
      <Cell ss:StyleID="s23"><Data ss:Type="String">dedcode</Data></Cell>
      <Cell ss:StyleID="s23"><Data ss:Type="String">dedcurrent</Data></Cell>
      <Cell><Data ss:Type="Number">1000</Data></Cell>
      <Cell><Data ss:Type="String">SAVE</Data></Cell>
      <Cell><Data ss:Type="Number">500</Data></Cell>

      For XML Clock, decode, dedcurrent, 1000, SAVE, 500 are indentical.
      What you want to get back exactly ?
      Patrick

      Comment


      • #4
        Re: Anyone have any experience with XML-into?

        The values of "CLOCK", "DECODE", and "DEDCURRENT" is the data thats contained elements called "CELL". If I believe I know what you are trying to do, your XML code needs to change each of the "CELL" names to "CLOCK", "DECODE", and "DEDCURRENT", and then the values of those cells need to contain the actual value represented by the clock cell, the decode cell, and the decurrent cell.


        You probably didnt get anything the way the program is run, because XML-Into did not find any elements named Clock, Decode, or Deccurrent. If you were to change one of those elements in your datastructure to "CELL", it would likely get filled with "CLOCK",which is the value of the element.
        Last edited by MichaelCatalani; June 30, 2010, 09:22 AM.
        Michael Catalani
        IS Director, eCommerce & Web Development
        Acceptance Insurance Corporation
        www.AcceptanceInsurance.com
        www.ProvatoSys.com

        Comment


        • #5
          Re: Anyone have any experience with XML-into?

          Originally posted by MichaelCatalani View Post
          The values of "CLOCK", "DECODE", and "DEDCURRENT" is the data thats contained elements called "CELL". If I believe I know what you are trying to do, your XML code needs to change each of the "CELL" names to "CLOCK", "DECODE", and "DEDCURRENT", and then the values of those cells need to contain the actual value represented by the clock cell, the decode cell, and the decurrent cell.


          You probably didnt get anything the way the program is run, because XML-Into did not find any elements named Clock, Decode, or Deccurrent. If you were to change one of those elements in your datastructure to "CELL", it would likely get filled with "CLOCK",which is the value of the element.
          Not "CELL" but "DATA"
          Patrick

          Comment


          • #6
            Re: Anyone have any experience with XML-into?

            This table is coming outta another software package as is....
            Looks like I will have to just read it and write (roll) my own.

            Thanks Guys
            Jamie
            All my answers were extracted from the "Big Dummy's Guide to the As400"
            and I take no responsibility for any of them.

            www.code400.com

            Comment


            • #7
              Re: Anyone have any experience with XML-into?

              Originally posted by jamief View Post
              This table is coming outta another software package as is....
              Looks like I will have to just read it and write (roll) my own.

              Thanks Guys
              Jamie
              Yea, I have to do this a lot. (At least convert the existing XML) Most times, its because the element names have an underscore character in them, which screws with setting up the corresponding data structure.

              Let me guess, this is some Kronos stuff.
              Michael Catalani
              IS Director, eCommerce & Web Development
              Acceptance Insurance Corporation
              www.AcceptanceInsurance.com
              www.ProvatoSys.com

              Comment


              • #8
                Re: Anyone have any experience with XML-into?

                i haven't mess with it much but have you looked at the XML-SAX? or Scott Klement has a port of Expat for the system on his website as well that you might find useful
                I'm not anti-social, I just don't like people -Tommy Holden

                Comment


                • #9
                  Re: Anyone have any experience with XML-into?

                  Originally posted by K2r400 View Post
                  Not "CELL" but "DATA"
                  Yea, when I copied the xml into a source editor, I was able to read it better and see that.
                  Michael Catalani
                  IS Director, eCommerce & Web Development
                  Acceptance Insurance Corporation
                  www.AcceptanceInsurance.com
                  www.ProvatoSys.com

                  Comment


                  • #10
                    Re: Anyone have any experience with XML-into?

                    Michael
                    It is Kronis Stuff You are the winner ...


                    jamie
                    All my answers were extracted from the "Big Dummy's Guide to the As400"
                    and I take no responsibility for any of them.

                    www.code400.com

                    Comment


                    • #11
                      Re: Anyone have any experience with XML-into?

                      Below the program. Say me if you want to get back the attributes too like StyleID, Type etc...

                      Code:
                      H Option(*NoDebugIO : *SrcStmt )                               
                      D table           DS                  Qualified                
                      D   row                               LikeDS(row)    Dim(1000) 
                      D row             DS                  Qualified                
                      D   cell                              LikeDS(cell) Dim(20)     
                      D cell            DS                  Qualified                
                      D  data                         20a                            
                      D XML_Source      S            256a   Varying                  
                      D                                     Inz('/XML/Example.xml')  
                                                                                     
                      D i               S              5i 0                          
                      D j               S              5i 0                          
                      /Free                                                    
                                                                               
                       XML-INTO table    %XML(XML_Source: 'case=any +          
                                                           doc=file +          
                                                           allowmissing=yes +  
                                                           allowextra=yes');   
                       For i = 1 to 2;                                         
                          For j = 1 to 3;                                      
                             Dsply ('Category: ' + table.row(i).cell(j).Data); 
                          EndFor;                                              
                       EndFor;                                                 
                                                                               
                       *InLR = *On;                                            
                      /end-Free
                      The result :

                      Code:
                      DSPLY  Category: clock      
                      DSPLY  Category: dedcode    
                      DSPLY  Category: dedcurrent 
                      DSPLY  Category: 1000       
                      DSPLY  Category: SAVE       
                      DSPLY  Category: 500
                      Patrick

                      Comment

                      Working...
                      X